Skip to content

Fix duplicate identifier error with module.exports #24466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20418,7 +20418,7 @@ namespace ts {
if (propType.symbol && propType.symbol.flags & SymbolFlags.Class) {
const name = prop.escapedName;
const symbol = resolveName(prop.valueDeclaration, name, SymbolFlags.Type, undefined, name, /*isUse*/ false);
if (symbol) {
if (symbol && propType.symbol !== symbol) {
grammarErrorOnNode(symbol.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
return grammarErrorOnNode(prop.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
}
Expand Down
14 changes: 14 additions & 0 deletions tests/baselines/reference/moduleExportAlias3.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/conformance/salsa/bug24062.js ===
// #24062
class C {
>C : Symbol(C, Decl(bug24062.js, 0, 0))
}
module.exports = {
>module : Symbol(export=, Decl(bug24062.js, 2, 1))
>exports : Symbol(export=, Decl(bug24062.js, 2, 1))

C
>C : Symbol(C, Decl(bug24062.js, 3, 18))

};

17 changes: 17 additions & 0 deletions tests/baselines/reference/moduleExportAlias3.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/conformance/salsa/bug24062.js ===
// #24062
class C {
>C : C
}
module.exports = {
>module.exports = { C} : { [x: string]: any; C: typeof C; }
>module.exports : any
>module : any
>exports : any
>{ C} : { [x: string]: any; C: typeof C; }

C
>C : typeof C

};

10 changes: 10 additions & 0 deletions tests/cases/conformance/salsa/moduleExportAlias3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @checkJs: true
// @allowJS: true
// @noEmit: true
// @Filename: bug24062.js
// #24062
class C {
}
module.exports = {
C
};