Better fix for bogus duplicate identifier in module exports (#24491)

This commit is contained in:
Nathan Shively-Sanders 2018-05-30 09:59:14 -07:00 committed by GitHub
parent fc3e88e26f
commit 22cdff59e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 1 deletions

View File

@ -20428,7 +20428,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 && propType.symbol !== symbol) {
if (symbol && symbol.declarations.some(d => d.kind === SyntaxKind.JSDocTypedefTag)) {
grammarErrorOnNode(symbol.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
return grammarErrorOnNode(prop.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name));
}

View File

@ -0,0 +1,18 @@
=== tests/cases/conformance/salsa/bug24024.js ===
// #24024
var wat = require('./bug24024')
>wat : Symbol(wat, Decl(bug24024.js, 1, 3))
>require : Symbol(require)
>'./bug24024' : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0))
module.exports = class C {}
>module : Symbol(export=, Decl(bug24024.js, 1, 31))
>exports : Symbol(export=, Decl(bug24024.js, 1, 31))
>C : Symbol(C, Decl(bug24024.js, 2, 16))
module.exports.D = class D { }
>module.exports : Symbol(D, Decl(bug24024.js, 2, 27))
>module : Symbol(module)
>D : Symbol(D, Decl(bug24024.js, 2, 27))
>D : Symbol(D, Decl(bug24024.js, 3, 18))

View File

@ -0,0 +1,26 @@
=== tests/cases/conformance/salsa/bug24024.js ===
// #24024
var wat = require('./bug24024')
>wat : typeof C
>require('./bug24024') : typeof C
>require : any
>'./bug24024' : "./bug24024"
module.exports = class C {}
>module.exports = class C {} : typeof C
>module.exports : any
>module : any
>exports : any
>class C {} : typeof C
>C : typeof C
module.exports.D = class D { }
>module.exports.D = class D { } : typeof D
>module.exports.D : any
>module.exports : any
>module : any
>exports : any
>D : any
>class D { } : typeof D
>D : typeof D

View File

@ -0,0 +1,8 @@
// @checkJs: true
// @allowJS: true
// @noEmit: true
// @Filename: bug24024.js
// #24024
var wat = require('./bug24024')
module.exports = class C {}
module.exports.D = class D { }