Fix property assignment on aliases (#24659)
Aliases don't have valueDeclarations, which caused a crash when passed to isJavascriptContainer before.
This commit is contained in:
parent
f9530d7e8f
commit
7db4b1cbc7
|
@ -2510,11 +2510,12 @@ namespace ts {
|
|||
* - with non-empty object literals if assigned to the prototype property
|
||||
*/
|
||||
function isJavascriptContainer(symbol: Symbol): boolean {
|
||||
const node = symbol.valueDeclaration;
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.NamespaceModule)) {
|
||||
return true;
|
||||
}
|
||||
const init = isVariableDeclaration(node) ? node.initializer :
|
||||
const node = symbol.valueDeclaration;
|
||||
const init = !node ? undefined :
|
||||
isVariableDeclaration(node) ? node.initializer :
|
||||
isBinaryExpression(node) ? node.right :
|
||||
isPropertyAccessExpression(node) && isBinaryExpression(node.parent) ? node.parent.right :
|
||||
undefined;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/conformance/salsa/mod1.js ===
|
||||
export var hurk = {}
|
||||
>hurk : Symbol(hurk, Decl(mod1.js, 0, 10))
|
||||
|
||||
=== tests/cases/conformance/salsa/bug24658.js ===
|
||||
import { hurk } from './mod1'
|
||||
>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8))
|
||||
|
||||
hurk.expando = 4
|
||||
>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
=== tests/cases/conformance/salsa/mod1.js ===
|
||||
export var hurk = {}
|
||||
>hurk : { [x: string]: any; }
|
||||
>{} : { [x: string]: any; }
|
||||
|
||||
=== tests/cases/conformance/salsa/bug24658.js ===
|
||||
import { hurk } from './mod1'
|
||||
>hurk : { [x: string]: any; }
|
||||
|
||||
hurk.expando = 4
|
||||
>hurk.expando = 4 : 4
|
||||
>hurk.expando : any
|
||||
>hurk : { [x: string]: any; }
|
||||
>expando : any
|
||||
>4 : 4
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @Filename: mod1.js
|
||||
export var hurk = {}
|
||||
// @Filename: bug24658.js
|
||||
import { hurk } from './mod1'
|
||||
hurk.expando = 4
|
Loading…
Reference in a new issue