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