mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix crash in assigning function with this ref to alias (#34650)
This commit is contained in:
parent
1cbbe288ac
commit
479d30646f
@ -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
|
||||
|
||||
@ -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'.
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user