Skip to content

Commit 7db4b1c

Browse files
authored
Fix property assignment on aliases (microsoft#24659)
Aliases don't have valueDeclarations, which caused a crash when passed to isJavascriptContainer before.
1 parent f9530d7 commit 7db4b1c

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

src/compiler/binder.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,11 +2510,12 @@ namespace ts {
25102510
* - with non-empty object literals if assigned to the prototype property
25112511
*/
25122512
function isJavascriptContainer(symbol: Symbol): boolean {
2513-
const node = symbol.valueDeclaration;
25142513
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.NamespaceModule)) {
25152514
return true;
25162515
}
2517-
const init = isVariableDeclaration(node) ? node.initializer :
2516+
const node = symbol.valueDeclaration;
2517+
const init = !node ? undefined :
2518+
isVariableDeclaration(node) ? node.initializer :
25182519
isBinaryExpression(node) ? node.right :
25192520
isPropertyAccessExpression(node) && isBinaryExpression(node.parent) ? node.parent.right :
25202521
undefined;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/conformance/salsa/mod1.js ===
2+
export var hurk = {}
3+
>hurk : Symbol(hurk, Decl(mod1.js, 0, 10))
4+
5+
=== tests/cases/conformance/salsa/bug24658.js ===
6+
import { hurk } from './mod1'
7+
>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8))
8+
9+
hurk.expando = 4
10+
>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8))
11+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/salsa/mod1.js ===
2+
export var hurk = {}
3+
>hurk : { [x: string]: any; }
4+
>{} : { [x: string]: any; }
5+
6+
=== tests/cases/conformance/salsa/bug24658.js ===
7+
import { hurk } from './mod1'
8+
>hurk : { [x: string]: any; }
9+
10+
hurk.expando = 4
11+
>hurk.expando = 4 : 4
12+
>hurk.expando : any
13+
>hurk : { [x: string]: any; }
14+
>expando : any
15+
>4 : 4
16+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
// @Filename: mod1.js
5+
export var hurk = {}
6+
// @Filename: bug24658.js
7+
import { hurk } from './mod1'
8+
hurk.expando = 4

0 commit comments

Comments
 (0)