mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix crash in expando assignment to alias (#34566)
* Fix crash in expando assignment to alias This PR disallows expando assignments Fixes #34493, but disallows the prototype assignment nonetheless. * Revert mistaken changes
This commit is contained in:
parent
1d5add528d
commit
fa1884ed1b
@ -2870,7 +2870,7 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (containerIsClass && namespaceSymbol) {
|
||||
if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
|
||||
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, SymbolFlags.Class);
|
||||
}
|
||||
return namespaceSymbol;
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
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/mod1.js (0 errors) ====
|
||||
class Alias {
|
||||
bar() { return 1 }
|
||||
}
|
||||
module.exports = Alias;
|
||||
|
||||
==== tests/cases/conformance/salsa/main.js (2 errors) ====
|
||||
import A from './mod1'
|
||||
A.prototype.foo = 0
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Alias'.
|
||||
new A().bar
|
||||
new A().foo
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Alias'.
|
||||
|
||||
30
tests/baselines/reference/importAliasModuleExports.symbols
Normal file
30
tests/baselines/reference/importAliasModuleExports.symbols
Normal file
@ -0,0 +1,30 @@
|
||||
=== tests/cases/conformance/salsa/mod1.js ===
|
||||
class Alias {
|
||||
>Alias : Symbol(Alias, Decl(mod1.js, 0, 0))
|
||||
|
||||
bar() { return 1 }
|
||||
>bar : Symbol(Alias.bar, Decl(mod1.js, 0, 13))
|
||||
}
|
||||
module.exports = Alias;
|
||||
>module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0))
|
||||
>module : Symbol(export=, Decl(mod1.js, 2, 1))
|
||||
>exports : Symbol(export=, Decl(mod1.js, 2, 1))
|
||||
>Alias : Symbol(Alias, Decl(mod1.js, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/salsa/main.js ===
|
||||
import A from './mod1'
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
|
||||
A.prototype.foo = 0
|
||||
>A.prototype : Symbol(A.prototype)
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
>prototype : Symbol(A.prototype)
|
||||
|
||||
new A().bar
|
||||
>new A().bar : Symbol(A.bar, Decl(mod1.js, 0, 13))
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
>bar : Symbol(A.bar, Decl(mod1.js, 0, 13))
|
||||
|
||||
new A().foo
|
||||
>A : Symbol(A, Decl(main.js, 0, 6))
|
||||
|
||||
40
tests/baselines/reference/importAliasModuleExports.types
Normal file
40
tests/baselines/reference/importAliasModuleExports.types
Normal file
@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/salsa/mod1.js ===
|
||||
class Alias {
|
||||
>Alias : Alias
|
||||
|
||||
bar() { return 1 }
|
||||
>bar : () => number
|
||||
>1 : 1
|
||||
}
|
||||
module.exports = Alias;
|
||||
>module.exports = Alias : typeof Alias
|
||||
>module.exports : typeof Alias
|
||||
>module : { "tests/cases/conformance/salsa/mod1": typeof Alias; }
|
||||
>exports : typeof Alias
|
||||
>Alias : typeof Alias
|
||||
|
||||
=== tests/cases/conformance/salsa/main.js ===
|
||||
import A from './mod1'
|
||||
>A : typeof A
|
||||
|
||||
A.prototype.foo = 0
|
||||
>A.prototype.foo = 0 : 0
|
||||
>A.prototype.foo : any
|
||||
>A.prototype : A
|
||||
>A : typeof A
|
||||
>prototype : A
|
||||
>foo : any
|
||||
>0 : 0
|
||||
|
||||
new A().bar
|
||||
>new A().bar : () => number
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
>bar : () => number
|
||||
|
||||
new A().foo
|
||||
>new A().foo : any
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
>foo : any
|
||||
|
||||
15
tests/cases/conformance/salsa/importAliasModuleExports.ts
Normal file
15
tests/cases/conformance/salsa/importAliasModuleExports.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @esModuleInterop: true
|
||||
// @filename: mod1.js
|
||||
class Alias {
|
||||
bar() { return 1 }
|
||||
}
|
||||
module.exports = Alias;
|
||||
|
||||
// @filename: main.js
|
||||
import A from './mod1'
|
||||
A.prototype.foo = 0
|
||||
new A().bar
|
||||
new A().foo
|
||||
Loading…
x
Reference in New Issue
Block a user