Skip to content

Commit ddcd22e

Browse files
committed
Removed esnext dependency on convertForOf/transformFunctionBody in factory
1 parent cbdde42 commit ddcd22e

File tree

4 files changed

+204
-121
lines changed

4 files changed

+204
-121
lines changed

src/compiler/factory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,8 @@ namespace ts {
15281528
return <Expression>createBinary(left, SyntaxKind.LessThanToken, right, location);
15291529
}
15301530

1531+
export function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment;
1532+
export function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression;
15311533
export function createAssignment(left: Expression, right: Expression, location?: TextRange) {
15321534
return createBinary(left, SyntaxKind.EqualsToken, right, location);
15331535
}
@@ -2345,7 +2347,7 @@ namespace ts {
23452347
if (isBlock(node)) {
23462348
return node;
23472349
}
2348-
return createBlock([createReturn(node, node)], node);
2350+
return createBlock([createReturn(node, node)], node, /*multiLine*/ true);
23492351
}
23502352

23512353
function isUseStrictPrologue(node: ExpressionStatement): boolean {

src/compiler/transformers/destructuring.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace ts {
5454
}
5555
}
5656

57-
const expressions: Expression[] = [];
57+
let expressions: Expression[];
5858
const host: FlattenHost = {
5959
context,
6060
level,
@@ -92,17 +92,21 @@ namespace ts {
9292
flattenBindingOrAssignmentElement(host, node, value, location, /*skipInitializer*/ isDestructuringAssignment(node));
9393

9494
if (value && needsValue) {
95+
if (!some(expressions)) {
96+
return value;
97+
}
98+
9599
expressions.push(value);
96100
}
97101

98-
return aggregateTransformFlags(inlineExpressions(expressions));
102+
return aggregateTransformFlags(inlineExpressions(expressions)) || createOmittedExpression();
99103

100104
function emitExpression(expression: Expression) {
101105
// NOTE: this completely disables source maps, but aligns with the behavior of
102106
// `emitAssignment` in the old emitter.
103107
setEmitFlags(expression, EmitFlags.NoNestedSourceMaps);
104108
aggregateTransformFlags(expression);
105-
expressions.push(expression);
109+
expressions = append(expressions, expression);
106110
}
107111

108112
function emitBindingOrAssignment(target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) {

0 commit comments

Comments
 (0)