mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Component commits: 9c0fab93b2 Fix crash with Object.defineProperty for imported alias (--allowJs) Fixes #35196
This commit is contained in:
parent
c18d72f220
commit
b9d52319ef
@ -2792,7 +2792,7 @@ namespace ts {
|
||||
|
||||
function bindObjectDefinePrototypeProperty(node: BindableObjectDefinePropertyCall) {
|
||||
const namespaceSymbol = lookupSymbolForPropertyAccess((node.arguments[0] as PropertyAccessExpression).expression as EntityNameExpression);
|
||||
if (namespaceSymbol) {
|
||||
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
|
||||
// Ensure the namespace symbol becomes class-like
|
||||
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, SymbolFlags.Class);
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
tests/cases/conformance/salsa/main.js(2,13): 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/main.js(6,9): error TS2339: Property 'foo' does not exist on type 'Alias'.
|
||||
tests/cases/conformance/salsa/main.js(7,9): error TS2339: Property 'func' does not exist on type 'Alias'.
|
||||
tests/cases/conformance/salsa/main.js(8,9): error TS2339: Property 'def' does not exist on type 'Alias'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/mod1.js (0 errors) ====
|
||||
@ -11,7 +12,7 @@ tests/cases/conformance/salsa/main.js(6,9): error TS2339: Property 'func' does n
|
||||
}
|
||||
module.exports = Alias;
|
||||
|
||||
==== tests/cases/conformance/salsa/main.js (5 errors) ====
|
||||
==== tests/cases/conformance/salsa/main.js (6 errors) ====
|
||||
import A from './mod1'
|
||||
A.prototype.foo = 0
|
||||
~~~
|
||||
@ -21,6 +22,7 @@ tests/cases/conformance/salsa/main.js(6,9): error TS2339: Property 'func' does n
|
||||
!!! error TS2339: Property 'func' does not exist on type 'Alias'.
|
||||
~~~~~
|
||||
!!! error TS2339: Property '_func' does not exist on type 'Alias'.
|
||||
Object.defineProperty(A.prototype, "def", { value: 0 });
|
||||
new A().bar
|
||||
new A().foo
|
||||
~~~
|
||||
@ -28,4 +30,7 @@ tests/cases/conformance/salsa/main.js(6,9): error TS2339: Property 'func' does n
|
||||
new A().func()
|
||||
~~~~
|
||||
!!! error TS2339: Property 'func' does not exist on type 'Alias'.
|
||||
new A().def
|
||||
~~~
|
||||
!!! error TS2339: Property 'def' does not exist on type 'Alias'.
|
||||
|
||||
@ -26,6 +26,15 @@ A.prototype.func = function() { this._func = 0; }
|
||||
>prototype : Symbol(A.prototype)
|
||||
>this : Symbol(A, Decl(mod1.js, 0, 0))
|
||||
|
||||
Object.defineProperty(A.prototype, "def", { value: 0 });
|
||||
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
||||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
||||
>A.prototype : Symbol(A.prototype)
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
>prototype : Symbol(A.prototype)
|
||||
>value : Symbol(value, Decl(main.js, 3, 43))
|
||||
|
||||
new A().bar
|
||||
>new A().bar : Symbol(A.bar, Decl(mod1.js, 0, 13))
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
@ -37,3 +46,6 @@ new A().foo
|
||||
new A().func()
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
|
||||
new A().def
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
|
||||
|
||||
@ -40,6 +40,19 @@ A.prototype.func = function() { this._func = 0; }
|
||||
>_func : any
|
||||
>0 : 0
|
||||
|
||||
Object.defineProperty(A.prototype, "def", { value: 0 });
|
||||
>Object.defineProperty(A.prototype, "def", { value: 0 }) : any
|
||||
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
|
||||
>Object : ObjectConstructor
|
||||
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
|
||||
>A.prototype : A
|
||||
>A : typeof A
|
||||
>prototype : A
|
||||
>"def" : "def"
|
||||
>{ value: 0 } : { value: number; }
|
||||
>value : number
|
||||
>0 : 0
|
||||
|
||||
new A().bar
|
||||
>new A().bar : () => number
|
||||
>new A() : A
|
||||
@ -59,3 +72,9 @@ new A().func()
|
||||
>A : typeof A
|
||||
>func : any
|
||||
|
||||
new A().def
|
||||
>new A().def : any
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
>def : any
|
||||
|
||||
|
||||
@ -12,6 +12,8 @@ module.exports = Alias;
|
||||
import A from './mod1'
|
||||
A.prototype.foo = 0
|
||||
A.prototype.func = function() { this._func = 0; }
|
||||
Object.defineProperty(A.prototype, "def", { value: 0 });
|
||||
new A().bar
|
||||
new A().foo
|
||||
new A().func()
|
||||
new A().def
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user