fix(ivy): add names to function expressions (#21714)

PR Close #21714
This commit is contained in:
Chuck Jazdzewski
2018-01-22 15:35:18 -08:00
committed by Miško Hevery
parent f11b2fb00b
commit 8baff1858b
6 changed files with 63 additions and 43 deletions

View File

@ -30,10 +30,10 @@ export class TypeScriptNodeEmitter {
const commentStmt = this.createCommentStatement(sourceFile, preamble);
preambleStmts.push(commentStmt);
}
const sourceStatments =
const sourceStatements =
[...preambleStmts, ...converter.getReexports(), ...converter.getImports(), ...statements];
converter.updateSourceMap(sourceStatments);
const newSourceFile = ts.updateSourceFileNode(sourceFile, sourceStatments);
converter.updateSourceMap(sourceStatements);
const newSourceFile = ts.updateSourceFileNode(sourceFile, sourceStatements);
return [newSourceFile, converter.getNodeMap()];
}
@ -143,7 +143,7 @@ function firstAfter<T>(a: T[], predicate: (value: T) => boolean) {
return index;
}
// A recorded node is a subtype of the node that is marked as being recoreded. This is used
// A recorded node is a subtype of the node that is marked as being recorded. This is used
// to ensure that NodeEmitterVisitor.record has been called on all nodes returned by the
// NodeEmitterVisitor
type RecordedNode<T extends ts.Node = ts.Node> = (T & { __recorded: any; }) | null;
@ -498,7 +498,8 @@ class _NodeEmitterVisitor implements StatementVisitor, ExpressionVisitor {
visitFunctionExpr(expr: FunctionExpr) {
return this.record(
expr, ts.createFunctionExpression(
/* modifiers */ undefined, /* astriskToken */ undefined, /* name */ undefined,
/* modifiers */ undefined, /* astriskToken */ undefined,
/* name */ expr.name || undefined,
/* typeParameters */ undefined,
expr.params.map(
p => ts.createParameter(