@@ -2566,62 +2566,53 @@ namespace ts {
2566
2566
* @param node An ObjectLiteralExpression node.
2567
2567
*/
2568
2568
function visitObjectLiteralExpression ( node : ObjectLiteralExpression ) : Expression {
2569
- // We are here because a ComputedPropertyName was used somewhere in the expression.
2570
2569
const properties = node . properties ;
2571
- const numProperties = properties . length ;
2572
2570
2573
2571
// Find the first computed property.
2574
2572
// Everything until that point can be emitted as part of the initial object literal.
2575
- let numInitialProperties = numProperties ;
2576
- let numInitialPropertiesWithoutYield = numProperties ;
2577
- for ( let i = 0 ; i < numProperties ; i ++ ) {
2573
+ let numInitialProperties = - 1 ;
2574
+ for ( let i = 0 ; i < properties . length ; i ++ ) {
2578
2575
const property = properties [ i ] ;
2579
- if ( ( property . transformFlags & TransformFlags . ContainsYield && hierarchyFacts & HierarchyFacts . AsyncFunctionBody )
2580
- && i < numInitialPropertiesWithoutYield ) {
2581
- numInitialPropertiesWithoutYield = i ;
2582
- }
2583
- if ( Debug . checkDefined ( property . name ) . kind === SyntaxKind . ComputedPropertyName ) {
2576
+ if ( Debug . checkDefined ( property . name ) . kind === SyntaxKind . ComputedPropertyName
2577
+ || ( property . transformFlags & TransformFlags . ContainsYield && hierarchyFacts & HierarchyFacts . AsyncFunctionBody ) ) {
2584
2578
numInitialProperties = i ;
2585
2579
break ;
2586
2580
}
2587
2581
}
2588
2582
2589
- if ( numInitialProperties !== numProperties ) {
2590
- if ( numInitialPropertiesWithoutYield < numInitialProperties ) {
2591
- numInitialProperties = numInitialPropertiesWithoutYield ;
2592
- }
2583
+ if ( numInitialProperties < 0 ) {
2584
+ return visitEachChild ( node , visitor , context ) ;
2585
+ }
2593
2586
2594
- // For computed properties, we need to create a unique handle to the object
2595
- // literal so we can modify it without risking internal assignments tainting the object.
2596
- const temp = createTempVariable ( hoistVariableDeclaration ) ;
2587
+ // For computed properties, we need to create a unique handle to the object
2588
+ // literal so we can modify it without risking internal assignments tainting the object.
2589
+ const temp = createTempVariable ( hoistVariableDeclaration ) ;
2597
2590
2598
- // Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
2599
- const expressions : Expression [ ] = [ ] ;
2600
- const assignment = createAssignment (
2601
- temp ,
2602
- setEmitFlags (
2603
- createObjectLiteral (
2604
- visitNodes ( properties , visitor , isObjectLiteralElementLike , 0 , numInitialProperties ) ,
2605
- node . multiLine
2606
- ) ,
2607
- EmitFlags . Indented
2608
- )
2609
- ) ;
2591
+ // Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
2592
+ const expressions : Expression [ ] = [ ] ;
2593
+ const assignment = createAssignment (
2594
+ temp ,
2595
+ setEmitFlags (
2596
+ createObjectLiteral (
2597
+ visitNodes ( properties , visitor , isObjectLiteralElementLike , 0 , numInitialProperties ) ,
2598
+ node . multiLine
2599
+ ) ,
2600
+ EmitFlags . Indented
2601
+ )
2602
+ ) ;
2610
2603
2611
- if ( node . multiLine ) {
2612
- startOnNewLine ( assignment ) ;
2613
- }
2604
+ if ( node . multiLine ) {
2605
+ startOnNewLine ( assignment ) ;
2606
+ }
2614
2607
2615
- expressions . push ( assignment ) ;
2608
+ expressions . push ( assignment ) ;
2616
2609
2617
- addObjectLiteralMembers ( expressions , node , temp , numInitialProperties ) ;
2610
+ addObjectLiteralMembers ( expressions , node , temp , numInitialProperties ) ;
2618
2611
2619
- // We need to clone the temporary identifier so that we can write it on a
2620
- // new line
2621
- expressions . push ( node . multiLine ? startOnNewLine ( getMutableClone ( temp ) ) : temp ) ;
2622
- return inlineExpressions ( expressions ) ;
2623
- }
2624
- return visitEachChild ( node , visitor , context ) ;
2612
+ // We need to clone the temporary identifier so that we can write it on a
2613
+ // new line
2614
+ expressions . push ( node . multiLine ? startOnNewLine ( getMutableClone ( temp ) ) : temp ) ;
2615
+ return inlineExpressions ( expressions ) ;
2625
2616
}
2626
2617
2627
2618
interface ForStatementWithConvertibleInitializer extends ForStatement {
0 commit comments