Skip to content

Commit 3a72c00

Browse files
committed
Emit generated name for unnamed default function in down-level code
1 parent 2dfe32a commit 3a72c00

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/compiler/emitter.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,16 +2935,14 @@ module ts {
29352935
}
29362936
}
29372937

2938-
function shouldEmitFunctionName(node: Declaration): boolean {
2939-
// Emit a declaration name for the function iff:
2940-
// it is a function expression with a name provided
2941-
// it is a function declaration with a name provided
2942-
// it is a function declaration is not the default export, and is missing a name (emit a generated name for it)
2938+
function shouldEmitFunctionName(node: FunctionLikeDeclaration) {
29432939
if (node.kind === SyntaxKind.FunctionExpression) {
2940+
// Emit name if one is present
29442941
return !!node.name;
29452942
}
2946-
else if (node.kind === SyntaxKind.FunctionDeclaration) {
2947-
return !!node.name || (languageVersion >= ScriptTarget.ES6 && !(node.flags & NodeFlags.Default));
2943+
if (node.kind === SyntaxKind.FunctionDeclaration) {
2944+
// Emit name if one is present, or emit generated name in down-level case (for export default case)
2945+
return !!node.name || languageVersion < ScriptTarget.ES6;
29482946
}
29492947
}
29502948

0 commit comments

Comments
 (0)