Skip to content

Commit 22cdff5

Browse files
authored
Better fix for bogus duplicate identifier in module exports (microsoft#24491)
1 parent fc3e88e commit 22cdff5

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20428,7 +20428,7 @@ namespace ts {
2042820428
if (propType.symbol && propType.symbol.flags & SymbolFlags.Class) {
2042920429
const name = prop.escapedName;
2043020430
const symbol = resolveName(prop.valueDeclaration, name, SymbolFlags.Type, undefined, name, /*isUse*/ false);
20431-
if (symbol && propType.symbol !== symbol) {
20431+
if (symbol && symbol.declarations.some(d => d.kind === SyntaxKind.JSDocTypedefTag)) {
2043220432
grammarErrorOnNode(symbol.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
2043320433
return grammarErrorOnNode(prop.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
2043420434
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/conformance/salsa/bug24024.js ===
2+
// #24024
3+
var wat = require('./bug24024')
4+
>wat : Symbol(wat, Decl(bug24024.js, 1, 3))
5+
>require : Symbol(require)
6+
>'./bug24024' : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0))
7+
8+
module.exports = class C {}
9+
>module : Symbol(export=, Decl(bug24024.js, 1, 31))
10+
>exports : Symbol(export=, Decl(bug24024.js, 1, 31))
11+
>C : Symbol(C, Decl(bug24024.js, 2, 16))
12+
13+
module.exports.D = class D { }
14+
>module.exports : Symbol(D, Decl(bug24024.js, 2, 27))
15+
>module : Symbol(module)
16+
>D : Symbol(D, Decl(bug24024.js, 2, 27))
17+
>D : Symbol(D, Decl(bug24024.js, 3, 18))
18+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/conformance/salsa/bug24024.js ===
2+
// #24024
3+
var wat = require('./bug24024')
4+
>wat : typeof C
5+
>require('./bug24024') : typeof C
6+
>require : any
7+
>'./bug24024' : "./bug24024"
8+
9+
module.exports = class C {}
10+
>module.exports = class C {} : typeof C
11+
>module.exports : any
12+
>module : any
13+
>exports : any
14+
>class C {} : typeof C
15+
>C : typeof C
16+
17+
module.exports.D = class D { }
18+
>module.exports.D = class D { } : typeof D
19+
>module.exports.D : any
20+
>module.exports : any
21+
>module : any
22+
>exports : any
23+
>D : any
24+
>class D { } : typeof D
25+
>D : typeof D
26+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @checkJs: true
2+
// @allowJS: true
3+
// @noEmit: true
4+
// @Filename: bug24024.js
5+
// #24024
6+
var wat = require('./bug24024')
7+
module.exports = class C {}
8+
module.exports.D = class D { }

0 commit comments

Comments
 (0)