Check for initializer before using it (#18708)

This commit is contained in:
Mohamed Hegazy
2017-09-22 17:14:22 -07:00
committed by GitHub
parent b2ec33389c
commit 4221fb6a39
4 changed files with 57 additions and 2 deletions
+1 -1
View File
@@ -16491,7 +16491,7 @@ namespace ts {
// If the symbol of the node has members, treat it like a constructor.
const symbol = isFunctionDeclaration(node) || isFunctionExpression(node) ? getSymbolOfNode(node) :
isVariableDeclaration(node) && isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) :
isVariableDeclaration(node) && node.initializer && isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) :
undefined;
return symbol && symbol.members !== undefined;
@@ -74,3 +74,23 @@ const c4_v2 = new C4();
>c4_v2 : Symbol(c4_v2, Decl(index.js, 30, 5))
>C4 : Symbol(C4, Decl(index.js, 25, 3))
var c5_v1;
>c5_v1 : Symbol(c5_v1, Decl(index.js, 32, 3))
c5_v1 = function f() { };
>c5_v1 : Symbol(c5_v1, Decl(index.js, 32, 3))
>f : Symbol(f, Decl(index.js, 33, 7))
new c5_v1();
>c5_v1 : Symbol(c5_v1, Decl(index.js, 32, 3))
var c5_v2;
>c5_v2 : Symbol(c5_v2, Decl(index.js, 36, 3))
c5_v2 = class { };
>c5_v2 : Symbol(c5_v2, Decl(index.js, 36, 3))
new c5_v2();
>c5_v2 : Symbol(c5_v2, Decl(index.js, 36, 3))
@@ -112,3 +112,29 @@ const c4_v2 = new C4();
>new C4() : {}
>C4 : () => any
var c5_v1;
>c5_v1 : any
c5_v1 = function f() { };
>c5_v1 = function f() { } : () => void
>c5_v1 : any
>function f() { } : () => void
>f : () => void
new c5_v1();
>new c5_v1() : any
>c5_v1 : () => void
var c5_v2;
>c5_v2 : any
c5_v2 = class { };
>c5_v2 = class { } : typeof (Anonymous class)
>c5_v2 : any
>class { } : typeof (Anonymous class)
new c5_v2();
>new c5_v2() : (Anonymous class)
>c5_v2 : typeof (Anonymous class)
@@ -33,4 +33,13 @@ var C4 = function () {
};
const c4_v1 = C4();
const c4_v2 = new C4();
const c4_v2 = new C4();
var c5_v1;
c5_v1 = function f() { };
new c5_v1();
var c5_v2;
c5_v2 = class { };
new c5_v2();