@@ -735,7 +735,7 @@ export class ProjectConfiguration {
735
735
private expectedFilePaths = new Set < string > ( ) ;
736
736
737
737
/**
738
- * List of resolved extra root directories to allow global typings to be loaded from.
738
+ * List of resolved extra root directories to allow global type declaration files to be loaded from.
739
739
*/
740
740
private typeRoots : string [ ] ;
741
741
@@ -873,15 +873,17 @@ export class ProjectConfiguration {
873
873
874
874
private ensuredBasicFiles = false ;
875
875
876
- private isTypeRootDeclaration ( path : string ) {
877
- if ( isDeclarationFile ( path ) ) {
878
- for ( const base of this . typeRoots ) {
879
- if ( path . startsWith ( base ) ) {
880
- return true ;
881
- }
882
- }
876
+ /**
877
+ * [isExpectedDeclarationFile description]
878
+ * @param {string } fileName [description]
879
+ */
880
+ private isExpectedDeclarationFile ( fileName : string ) {
881
+ if ( isDeclarationFile ( fileName ) ) {
882
+ return this . expectedFilePaths . has ( toUnixPath ( fileName ) ) ||
883
+ this . typeRoots . some ( root => fileName . startsWith ( root ) )
884
+ } else {
885
+ return false ;
883
886
}
884
- return false ;
885
887
}
886
888
887
889
/**
@@ -903,8 +905,7 @@ export class ProjectConfiguration {
903
905
for ( const uri of this . fs . uris ( ) ) {
904
906
const fileName = uri2path ( uri ) ;
905
907
if ( isGlobalTSFile ( fileName ) ||
906
- this . isTypeRootDeclaration ( fileName ) ||
907
- ( isDeclarationFile ( fileName ) && this . expectedFilePaths . has ( toUnixPath ( fileName ) ) ) ) {
908
+ this . isExpectedDeclarationFile ( fileName ) ) {
908
909
const sourceFile = program . getSourceFile ( fileName ) ;
909
910
if ( ! sourceFile ) {
910
911
this . getHost ( ) . addFile ( fileName ) ;
0 commit comments