@@ -1320,13 +1320,14 @@ namespace ts {
13201320 else { // error
13211321 const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum);
13221322 const isEitherBlockScoped = !!(target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable);
1323- const message = isEitherEnum
1324- ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
1325- : isEitherBlockScoped
1326- ? Diagnostics.Cannot_redeclare_block_scoped_variable_0
1327- : Diagnostics.Duplicate_identifier_0;
1323+ const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
1324+ : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0
1325+ : Diagnostics.Duplicate_identifier_0;
13281326 const sourceSymbolFile = source.declarations && getSourceFileOfNode(source.declarations[0]);
13291327 const targetSymbolFile = target.declarations && getSourceFileOfNode(target.declarations[0]);
1328+
1329+ const isSourcePlainJs = isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
1330+ const isTargetPlainJs = isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
13301331 const symbolName = symbolToString(source);
13311332
13321333 // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
@@ -1337,12 +1338,12 @@ namespace ts {
13371338 ({ firstFile, secondFile, conflictingSymbols: new Map() } as DuplicateInfoForFiles));
13381339 const conflictingSymbolInfo = getOrUpdate(filesDuplicates.conflictingSymbols, symbolName, () =>
13391340 ({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] } as DuplicateInfoForSymbol));
1340- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
1341- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
1341+ if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
1342+ if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
13421343 }
13431344 else {
1344- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName, target);
1345- addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source);
1345+ if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source, message, symbolName, target);
1346+ if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source);
13461347 }
13471348 }
13481349 return target;
0 commit comments