Skip to content

Commit 93a721c

Browse files
author
Yui T
committed
Bind classExpression and functionExpression to its name if the expression is declared with name
1 parent 71c6433 commit 93a721c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/compiler/binder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,8 @@ namespace ts {
892892
case SyntaxKind.FunctionExpression:
893893
case SyntaxKind.ArrowFunction:
894894
checkStrictModeFunctionName(<FunctionExpression>node);
895-
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function");
895+
let bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
896+
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
896897
case SyntaxKind.ClassExpression:
897898
case SyntaxKind.ClassDeclaration:
898899
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
@@ -964,7 +965,8 @@ namespace ts {
964965
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
965966
}
966967
else {
967-
bindAnonymousDeclaration(node, SymbolFlags.Class, "__class");
968+
let bindingName = node.name ? node.name.text : "__class";
969+
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
968970
}
969971

970972
let symbol = node.symbol;

0 commit comments

Comments
 (0)