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:
Nathan Shively-Sanders 2018-06-04 13:34:23 -07:00 committed by GitHub
parent f9530d7e8f
commit 7db4b1cbc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 2 deletions

View file

@ -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;

View file

@ -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))

View file

@ -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

View file

@ -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