@@ -330,7 +330,6 @@ namespace ts {
330330 let fileProcessingDiagnostics = createDiagnosticCollection ( ) ;
331331 let programDiagnostics = createDiagnosticCollection ( ) ;
332332 let emitBlockingDiagnostics = createDiagnosticCollection ( ) ;
333- let hasEmitBlockingDiagnostics : Map < boolean > = { } ; // Map storing if there is emit blocking diagnostics for given input
334333
335334 let commonSourceDirectory : string ;
336335 let diagnosticsProducingTypeChecker : TypeChecker ;
@@ -342,6 +341,8 @@ namespace ts {
342341 let start = new Date ( ) . getTime ( ) ;
343342
344343 host = host || createCompilerHost ( options ) ;
344+ // Map storing if there is emit blocking diagnostics for given input
345+ let hasEmitBlockingDiagnostics = createFileMap < boolean > ( ! host . useCaseSensitiveFileNames ( ) ? key => key . toLocaleLowerCase ( ) : undefined ) ;
345346
346347 const currentDirectory = host . getCurrentDirectory ( ) ;
347348 const resolveModuleNamesWorker = host . resolveModuleNames
@@ -547,7 +548,7 @@ namespace ts {
547548 }
548549
549550 function isEmitBlocked ( emitFileName : string ) : boolean {
550- return hasProperty ( hasEmitBlockingDiagnostics , emitFileName ) ;
551+ return hasEmitBlockingDiagnostics . contains ( toPath ( emitFileName , currentDirectory , getCanonicalFileName ) ) ;
551552 }
552553
553554 function emitWorker ( program : Program , sourceFile : SourceFile , writeFileCallback : WriteFileCallback , cancellationToken : CancellationToken ) : EmitResult {
@@ -1256,36 +1257,36 @@ namespace ts {
12561257
12571258 if ( ! options . noEmit ) {
12581259 let emitHost = getEmitHost ( ) ;
1259- let emitFilesSeen : Map < boolean > = { } ;
1260+ let emitFilesSeen = createFileMap < boolean > ( ! host . useCaseSensitiveFileNames ( ) ? key => key . toLocaleLowerCase ( ) : undefined ) ;
12601261 forEachExpectedEmitFile ( emitHost , ( emitFileNames , sourceFiles , isBundledEmit ) => {
12611262 verifyEmitFilePath ( emitFileNames . jsFilePath , emitFilesSeen ) ;
12621263 verifyEmitFilePath ( emitFileNames . declarationFilePath , emitFilesSeen ) ;
12631264 } ) ;
12641265 }
12651266
12661267 // Verify that all the emit files are unique and dont overwrite input files
1267- function verifyEmitFilePath ( emitFilePath : string , emitFilesSeen : Map < boolean > ) {
1268- if ( emitFilePath ) {
1268+ function verifyEmitFilePath ( emitFileName : string , emitFilesSeen : FileMap < boolean > ) {
1269+ if ( emitFileName ) {
1270+ let emitFilePath = toPath ( emitFileName , currentDirectory , getCanonicalFileName ) ;
12691271 // Report error if the output overwrites input file
1270- if ( hasFile ( files , emitFilePath ) ) {
1271- createEmitBlockingDiagnostics ( emitFilePath , Diagnostics . Cannot_write_file_0_because_it_would_overwrite_input_file ) ;
1272+ if ( forEach ( files , file => toPath ( file . fileName , currentDirectory , getCanonicalFileName ) === emitFilePath ) ) {
1273+ createEmitBlockingDiagnostics ( emitFileName , Diagnostics . Cannot_write_file_0_because_it_would_overwrite_input_file ) ;
12721274 }
12731275
12741276 // Report error if multiple files write into same file
1275- let filesEmittingJsFilePath = lookUp ( emitFilesSeen , emitFilePath ) ;
1276- if ( filesEmittingJsFilePath ) {
1277+ if ( emitFilesSeen . contains ( emitFilePath ) ) {
12771278 // Already seen the same emit file - report error
1278- createEmitBlockingDiagnostics ( emitFilePath , Diagnostics . Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files ) ;
1279+ createEmitBlockingDiagnostics ( emitFileName , Diagnostics . Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files ) ;
12791280 }
12801281 else {
1281- emitFilesSeen [ emitFilePath ] = true ;
1282+ emitFilesSeen . set ( emitFilePath , true ) ;
12821283 }
12831284 }
12841285 }
12851286 }
12861287
12871288 function createEmitBlockingDiagnostics ( emitFileName : string , message : DiagnosticMessage ) {
1288- hasEmitBlockingDiagnostics [ emitFileName ] = true ;
1289+ hasEmitBlockingDiagnostics . set ( toPath ( emitFileName , currentDirectory , getCanonicalFileName ) , true ) ;
12891290 emitBlockingDiagnostics . add ( createCompilerDiagnostic ( message , emitFileName ) ) ;
12901291 }
12911292 }
0 commit comments