@@ -2319,27 +2319,20 @@ namespace ts {
23192319 }
23202320
23212321 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 ) ;
23282323 return computeCommonSourceDirectoryOfFilenames ( fileNames , currentDirectory , getCanonicalFileName ) ;
23292324 }
23302325
2331- function checkSourceFilesBelongToPath ( sourceFiles : SourceFile [ ] , rootDirectory : string ) : boolean {
2326+ function checkSourceFilesBelongToPath ( sourceFiles : ReadonlyArray < SourceFile > , rootDirectory : string ) : boolean {
23322327 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 ;
23432336 }
23442337 }
23452338 }
0 commit comments