@@ -2319,27 +2319,20 @@ namespace ts {
2319
2319
}
2320
2320
2321
2321
function computeCommonSourceDirectory ( sourceFiles : SourceFile [ ] ) : string {
2322
- const fileNames : string [ ] = [ ] ;
2323
- for ( const file of sourceFiles ) {
2324
- if ( ! file . isDeclarationFile ) {
2325
- fileNames . push ( file . fileName ) ;
2326
- }
2327
- }
2322
+ const fileNames = mapDefined ( sourceFiles , file => file . isDeclarationFile ? undefined : file . fileName ) ;
2328
2323
return computeCommonSourceDirectoryOfFilenames ( fileNames , currentDirectory , getCanonicalFileName ) ;
2329
2324
}
2330
2325
2331
- function checkSourceFilesBelongToPath ( sourceFiles : SourceFile [ ] , rootDirectory : string ) : boolean {
2326
+ function checkSourceFilesBelongToPath ( sourceFiles : ReadonlyArray < SourceFile > , rootDirectory : string ) : boolean {
2332
2327
let allFilesBelongToPath = true ;
2333
- if ( sourceFiles ) {
2334
- const absoluteRootDirectoryPath = host . getCanonicalFileName ( getNormalizedAbsolutePath ( rootDirectory , currentDirectory ) ) ;
2335
-
2336
- for ( const sourceFile of sourceFiles ) {
2337
- if ( ! sourceFile . isDeclarationFile ) {
2338
- const absoluteSourceFilePath = host . getCanonicalFileName ( getNormalizedAbsolutePath ( sourceFile . fileName , currentDirectory ) ) ;
2339
- if ( absoluteSourceFilePath . indexOf ( absoluteRootDirectoryPath ) !== 0 ) {
2340
- programDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files , sourceFile . fileName , rootDirectory ) ) ;
2341
- allFilesBelongToPath = false ;
2342
- }
2328
+ const absoluteRootDirectoryPath = host . getCanonicalFileName ( getNormalizedAbsolutePath ( rootDirectory , currentDirectory ) ) ;
2329
+
2330
+ for ( const sourceFile of sourceFiles ) {
2331
+ if ( ! sourceFile . isDeclarationFile ) {
2332
+ const absoluteSourceFilePath = host . getCanonicalFileName ( getNormalizedAbsolutePath ( sourceFile . fileName , currentDirectory ) ) ;
2333
+ if ( absoluteSourceFilePath . indexOf ( absoluteRootDirectoryPath ) !== 0 ) {
2334
+ programDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files , sourceFile . fileName , rootDirectory ) ) ;
2335
+ allFilesBelongToPath = false ;
2343
2336
}
2344
2337
}
2345
2338
}
0 commit comments