@@ -6,7 +6,7 @@ namespace ts.Completions.PathCompletions {
66 const scriptPath = node . getSourceFile ( ) . path ;
77 const scriptDirectory = getDirectoryPath ( scriptPath ) ;
88
9- const span = getDirectoryFragmentTextSpan ( ( < StringLiteral > node ) . text , node . getStart ( sourceFile ) + 1 ) ;
9+ const span = getDirectoryFragmentTextSpan ( node . text , node . getStart ( sourceFile ) + 1 ) ;
1010 if ( isPathRelativeToScript ( literalValue ) || isRootedDiskPath ( literalValue ) ) {
1111 const extensions = getSupportedExtensions ( compilerOptions ) ;
1212 if ( compilerOptions . rootDirs ) {
@@ -226,7 +226,8 @@ namespace ts.Completions.PathCompletions {
226226 const includeGlob = normalizedSuffix ? "**/*" : "./*" ;
227227
228228 const matches = tryReadDirectory ( host , baseDirectory , fileExtensions , /*exclude*/ undefined , [ includeGlob ] ) ;
229- const directories = tryGetDirectories ( host , baseDirectory ) ;
229+ const directories = tryGetDirectories ( host , baseDirectory ) . map ( d => combinePaths ( baseDirectory , d ) ) ;
230+
230231 // Trim away prefix and suffix
231232 return mapDefined ( concatenate ( matches , directories ) , match => {
232233 const normalizedMatch = normalizePath ( match ) ;
@@ -476,14 +477,14 @@ namespace ts.Completions.PathCompletions {
476477 const nodeModulesDependencyKeys = [ "dependencies" , "devDependencies" , "peerDependencies" , "optionalDependencies" ] ;
477478
478479 function tryGetDirectories ( host : LanguageServiceHost , directoryName : string ) : string [ ] {
479- return tryIOAndConsumeErrors ( host , host . getDirectories , directoryName ) ;
480+ return tryIOAndConsumeErrors ( host , host . getDirectories , directoryName ) || [ ] ;
480481 }
481482
482- function tryReadDirectory ( host : LanguageServiceHost , path : string , extensions ?: ReadonlyArray < string > , exclude ?: ReadonlyArray < string > , include ?: ReadonlyArray < string > ) : string [ ] | undefined {
483+ function tryReadDirectory ( host : LanguageServiceHost , path : string , extensions ?: ReadonlyArray < string > , exclude ?: ReadonlyArray < string > , include ?: ReadonlyArray < string > ) : string [ ] | undefined | undefined {
483484 return tryIOAndConsumeErrors ( host , host . readDirectory , path , extensions , exclude , include ) ;
484485 }
485486
486- function tryReadFile ( host : LanguageServiceHost , path : string ) : string {
487+ function tryReadFile ( host : LanguageServiceHost , path : string ) : string | undefined {
487488 return tryIOAndConsumeErrors ( host , host . readFile , path ) ;
488489 }
489490
0 commit comments