diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e1fdfc258e0ce..1070020401062 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2709,7 +2709,7 @@ namespace ts { } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur diff --git a/tests/baselines/reference/importAliasModuleExports.errors.txt b/tests/baselines/reference/importAliasModuleExports.errors.txt index ea3dd9ef0e018..9cd2cd9768ecf 100644 --- a/tests/baselines/reference/importAliasModuleExports.errors.txt +++ b/tests/baselines/reference/importAliasModuleExports.errors.txt @@ -1,5 +1,8 @@ tests/cases/conformance/salsa/main.js(2,13): error TS2339: Property 'foo' does not exist on type 'Alias'. -tests/cases/conformance/salsa/main.js(4,9): error TS2339: Property 'foo' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(3,13): error TS2339: Property 'func' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(3,38): error TS2339: Property '_func' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(5,9): error TS2339: Property 'foo' does not exist on type 'Alias'. +tests/cases/conformance/salsa/main.js(6,9): error TS2339: Property 'func' does not exist on type 'Alias'. ==== tests/cases/conformance/salsa/mod1.js (0 errors) ==== @@ -8,13 +11,21 @@ tests/cases/conformance/salsa/main.js(4,9): error TS2339: Property 'foo' does no } module.exports = Alias; -==== tests/cases/conformance/salsa/main.js (2 errors) ==== +==== tests/cases/conformance/salsa/main.js (5 errors) ==== import A from './mod1' A.prototype.foo = 0 ~~~ !!! error TS2339: Property 'foo' does not exist on type 'Alias'. + A.prototype.func = function() { this._func = 0; } + ~~~~ +!!! error TS2339: Property 'func' does not exist on type 'Alias'. + ~~~~~ +!!! error TS2339: Property '_func' does not exist on type 'Alias'. new A().bar new A().foo ~~~ !!! error TS2339: Property 'foo' does not exist on type 'Alias'. + new A().func() + ~~~~ +!!! error TS2339: Property 'func' does not exist on type 'Alias'. \ No newline at end of file diff --git a/tests/baselines/reference/importAliasModuleExports.symbols b/tests/baselines/reference/importAliasModuleExports.symbols index 4ab081d608f8f..4d67eb8e197ef 100644 --- a/tests/baselines/reference/importAliasModuleExports.symbols +++ b/tests/baselines/reference/importAliasModuleExports.symbols @@ -20,6 +20,12 @@ A.prototype.foo = 0 >A : Symbol(A, Decl(main.js, 0, 6)) >prototype : Symbol(A.prototype) +A.prototype.func = function() { this._func = 0; } +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(main.js, 0, 6)) +>prototype : Symbol(A.prototype) +>this : Symbol(A, Decl(mod1.js, 0, 0)) + new A().bar >new A().bar : Symbol(A.bar, Decl(mod1.js, 0, 13)) >A : Symbol(A, Decl(main.js, 0, 6)) @@ -28,3 +34,6 @@ new A().bar new A().foo >A : Symbol(A, Decl(main.js, 0, 6)) +new A().func() +>A : Symbol(A, Decl(main.js, 0, 6)) + diff --git a/tests/baselines/reference/importAliasModuleExports.types b/tests/baselines/reference/importAliasModuleExports.types index 1303ba6e8c4b4..6c9b05095497e 100644 --- a/tests/baselines/reference/importAliasModuleExports.types +++ b/tests/baselines/reference/importAliasModuleExports.types @@ -26,6 +26,20 @@ A.prototype.foo = 0 >foo : any >0 : 0 +A.prototype.func = function() { this._func = 0; } +>A.prototype.func = function() { this._func = 0; } : () => void +>A.prototype.func : any +>A.prototype : A +>A : typeof A +>prototype : A +>func : any +>function() { this._func = 0; } : () => void +>this._func = 0 : 0 +>this._func : any +>this : A +>_func : any +>0 : 0 + new A().bar >new A().bar : () => number >new A() : A @@ -38,3 +52,10 @@ new A().foo >A : typeof A >foo : any +new A().func() +>new A().func() : any +>new A().func : any +>new A() : A +>A : typeof A +>func : any + diff --git a/tests/cases/conformance/salsa/importAliasModuleExports.ts b/tests/cases/conformance/salsa/importAliasModuleExports.ts index 5e850206676a2..691dde2026942 100644 --- a/tests/cases/conformance/salsa/importAliasModuleExports.ts +++ b/tests/cases/conformance/salsa/importAliasModuleExports.ts @@ -11,5 +11,7 @@ module.exports = Alias; // @filename: main.js import A from './mod1' A.prototype.foo = 0 +A.prototype.func = function() { this._func = 0; } new A().bar new A().foo +new A().func()