Skip to content

Commit a0b8da0

Browse files
committed
refactor
1 parent 5268b75 commit a0b8da0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/compiler/program.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,18 +1538,13 @@ namespace ts {
15381538
// Report error if the output overwrites input file
15391539
if (filesByName.contains(emitFilePath)) {
15401540
const sourceFile = filesByName.get(emitFilePath);
1541-
if (isSourceFileJavaScript(sourceFile) && options.noEmitOverwriteForJsFiles) {
1542-
blockEmitingOfFile(emitFileName);
1543-
}
1544-
else {
1545-
blockEmitingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
1546-
}
1541+
blockEmittingOfFile(emitFileName, options.noEmitOverwriteForJsFiles && isSourceFileJavaScript(sourceFile) && Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
15471542
}
15481543

15491544
// Report error if multiple files write into same file
15501545
if (emitFilesSeen.contains(emitFilePath)) {
15511546
// Already seen the same emit file - report error
1552-
blockEmitingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
1547+
blockEmittingOfFile(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
15531548
}
15541549
else {
15551550
emitFilesSeen.set(emitFilePath, true);
@@ -1558,7 +1553,7 @@ namespace ts {
15581553
}
15591554
}
15601555

1561-
function blockEmitingOfFile(emitFileName: string, message?: DiagnosticMessage) {
1556+
function blockEmittingOfFile(emitFileName: string, message?: DiagnosticMessage) {
15621557
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
15631558
if (message) {
15641559
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));

0 commit comments

Comments
 (0)