@@ -6,7 +6,7 @@ namespace ts.Completions.PathCompletions {
6
6
const scriptPath = node . getSourceFile ( ) . path ;
7
7
const scriptDirectory = getDirectoryPath ( scriptPath ) ;
8
8
9
- const span = getDirectoryFragmentTextSpan ( ( < StringLiteral > node ) . text , node . getStart ( sourceFile ) + 1 ) ;
9
+ const span = getDirectoryFragmentTextSpan ( node . text , node . getStart ( sourceFile ) + 1 ) ;
10
10
if ( isPathRelativeToScript ( literalValue ) || isRootedDiskPath ( literalValue ) ) {
11
11
const extensions = getSupportedExtensions ( compilerOptions ) ;
12
12
if ( compilerOptions . rootDirs ) {
@@ -226,7 +226,8 @@ namespace ts.Completions.PathCompletions {
226
226
const includeGlob = normalizedSuffix ? "**/*" : "./*" ;
227
227
228
228
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
+
230
231
// Trim away prefix and suffix
231
232
return mapDefined ( concatenate ( matches , directories ) , match => {
232
233
const normalizedMatch = normalizePath ( match ) ;
@@ -476,14 +477,14 @@ namespace ts.Completions.PathCompletions {
476
477
const nodeModulesDependencyKeys = [ "dependencies" , "devDependencies" , "peerDependencies" , "optionalDependencies" ] ;
477
478
478
479
function tryGetDirectories ( host : LanguageServiceHost , directoryName : string ) : string [ ] {
479
- return tryIOAndConsumeErrors ( host , host . getDirectories , directoryName ) ;
480
+ return tryIOAndConsumeErrors ( host , host . getDirectories , directoryName ) || [ ] ;
480
481
}
481
482
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 {
483
484
return tryIOAndConsumeErrors ( host , host . readDirectory , path , extensions , exclude , include ) ;
484
485
}
485
486
486
- function tryReadFile ( host : LanguageServiceHost , path : string ) : string {
487
+ function tryReadFile ( host : LanguageServiceHost , path : string ) : string | undefined {
487
488
return tryIOAndConsumeErrors ( host , host . readFile , path ) ;
488
489
}
489
490
0 commit comments