@@ -1196,7 +1196,7 @@ namespace ts {
1196
1196
*/
1197
1197
function transformAccessorsToStatement ( receiver : LeftHandSideExpression , accessors : AllAccessorDeclarations ) : Statement {
1198
1198
const statement = createStatement (
1199
- transformAccessorsToExpression ( receiver , accessors ) ,
1199
+ transformAccessorsToExpression ( receiver , accessors , /*startsOnNewLine*/ false ) ,
1200
1200
/*location*/ getSourceMapRange ( accessors . firstAccessor )
1201
1201
) ;
1202
1202
@@ -1213,7 +1213,7 @@ namespace ts {
1213
1213
*
1214
1214
* @param receiver The receiver for the member.
1215
1215
*/
1216
- function transformAccessorsToExpression ( receiver : LeftHandSideExpression , { firstAccessor, getAccessor, setAccessor } : AllAccessorDeclarations ) : Expression {
1216
+ function transformAccessorsToExpression ( receiver : LeftHandSideExpression , { firstAccessor, getAccessor, setAccessor } : AllAccessorDeclarations , startsOnNewLine : boolean ) : Expression {
1217
1217
// To align with source maps in the old emitter, the receiver and property name
1218
1218
// arguments are both mapped contiguously to the accessor name.
1219
1219
const target = getMutableClone ( receiver ) ;
@@ -1246,7 +1246,7 @@ namespace ts {
1246
1246
createPropertyAssignment ( "configurable" , createLiteral ( true ) )
1247
1247
) ;
1248
1248
1249
- return createCall (
1249
+ const call = createCall (
1250
1250
createPropertyAccess ( createIdentifier ( "Object" ) , "defineProperty" ) ,
1251
1251
/*typeArguments*/ undefined ,
1252
1252
[
@@ -1255,6 +1255,10 @@ namespace ts {
1255
1255
createObjectLiteral ( properties , /*location*/ undefined , /*multiLine*/ true )
1256
1256
]
1257
1257
) ;
1258
+ if ( startsOnNewLine ) {
1259
+ call . startsOnNewLine = true ;
1260
+ }
1261
+ return call ;
1258
1262
}
1259
1263
1260
1264
/**
@@ -1895,26 +1899,27 @@ namespace ts {
1895
1899
1896
1900
// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
1897
1901
const expressions : Expression [ ] = [ ] ;
1898
- addNode ( expressions ,
1899
- createAssignment (
1900
- temp ,
1901
- setNodeEmitFlags (
1902
- createObjectLiteral (
1903
- visitNodes ( properties , visitor , isObjectLiteralElement , 0 , numInitialProperties ) ,
1904
- /*location*/ undefined ,
1905
- node . multiLine
1906
- ) ,
1907
- NodeEmitFlags . Indented
1908
- )
1909
- ) ,
1910
- node . multiLine
1902
+ const assignment = createAssignment (
1903
+ temp ,
1904
+ setNodeEmitFlags (
1905
+ createObjectLiteral (
1906
+ visitNodes ( properties , visitor , isObjectLiteralElement , 0 , numInitialProperties ) ,
1907
+ /*location*/ undefined ,
1908
+ node . multiLine
1909
+ ) ,
1910
+ NodeEmitFlags . Indented
1911
+ )
1911
1912
) ;
1913
+ if ( node . multiLine ) {
1914
+ assignment . startsOnNewLine = true ;
1915
+ }
1916
+ expressions . push ( assignment ) ;
1912
1917
1913
1918
addObjectLiteralMembers ( expressions , node , temp , numInitialProperties ) ;
1914
1919
1915
1920
// We need to clone the temporary identifier so that we can write it on a
1916
1921
// new line
1917
- addNode ( expressions , getMutableClone ( temp ) , node . multiLine ) ;
1922
+ expressions . push ( node . multiLine ? startOnNewLine ( getMutableClone ( temp ) ) : temp ) ;
1918
1923
return inlineExpressions ( expressions ) ;
1919
1924
}
1920
1925
@@ -2313,21 +2318,21 @@ namespace ts {
2313
2318
case SyntaxKind . SetAccessor :
2314
2319
const accessors = getAllAccessorDeclarations ( node . properties , < AccessorDeclaration > property ) ;
2315
2320
if ( property === accessors . firstAccessor ) {
2316
- addNode ( expressions , transformAccessorsToExpression ( receiver , accessors ) , node . multiLine ) ;
2321
+ expressions . push ( transformAccessorsToExpression ( receiver , accessors , node . multiLine ) ) ;
2317
2322
}
2318
2323
2319
2324
break ;
2320
2325
2321
2326
case SyntaxKind . PropertyAssignment :
2322
- addNode ( expressions , transformPropertyAssignmentToExpression ( node , < PropertyAssignment > property , receiver ) , node . multiLine ) ;
2327
+ expressions . push ( transformPropertyAssignmentToExpression ( node , < PropertyAssignment > property , receiver , node . multiLine ) ) ;
2323
2328
break ;
2324
2329
2325
2330
case SyntaxKind . ShorthandPropertyAssignment :
2326
- addNode ( expressions , transformShorthandPropertyAssignmentToExpression ( node , < ShorthandPropertyAssignment > property , receiver ) , node . multiLine ) ;
2331
+ expressions . push ( transformShorthandPropertyAssignmentToExpression ( node , < ShorthandPropertyAssignment > property , receiver , node . multiLine ) ) ;
2327
2332
break ;
2328
2333
2329
2334
case SyntaxKind . MethodDeclaration :
2330
- addNode ( expressions , transformObjectLiteralMethodDeclarationToExpression ( node , < MethodDeclaration > property , receiver ) , node . multiLine ) ;
2335
+ expressions . push ( transformObjectLiteralMethodDeclarationToExpression ( node , < MethodDeclaration > property , receiver , node . multiLine ) ) ;
2331
2336
break ;
2332
2337
2333
2338
default :
@@ -2344,15 +2349,19 @@ namespace ts {
2344
2349
* @param property The PropertyAssignment node.
2345
2350
* @param receiver The receiver for the assignment.
2346
2351
*/
2347
- function transformPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : PropertyAssignment , receiver : Expression ) {
2348
- return createAssignment (
2352
+ function transformPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : PropertyAssignment , receiver : Expression , startsOnNewLine : boolean ) {
2353
+ const expression = createAssignment (
2349
2354
createMemberAccessForPropertyName (
2350
2355
receiver ,
2351
2356
visitNode ( property . name , visitor , isPropertyName )
2352
2357
) ,
2353
2358
visitNode ( property . initializer , visitor , isExpression ) ,
2354
2359
/*location*/ property
2355
2360
) ;
2361
+ if ( startsOnNewLine ) {
2362
+ expression . startsOnNewLine = true ;
2363
+ }
2364
+ return expression ;
2356
2365
}
2357
2366
2358
2367
/**
@@ -2362,15 +2371,19 @@ namespace ts {
2362
2371
* @param property The ShorthandPropertyAssignment node.
2363
2372
* @param receiver The receiver for the assignment.
2364
2373
*/
2365
- function transformShorthandPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : ShorthandPropertyAssignment , receiver : Expression ) {
2366
- return createAssignment (
2374
+ function transformShorthandPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : ShorthandPropertyAssignment , receiver : Expression , startsOnNewLine : boolean ) {
2375
+ const expression = createAssignment (
2367
2376
createMemberAccessForPropertyName (
2368
2377
receiver ,
2369
2378
visitNode ( property . name , visitor , isPropertyName )
2370
2379
) ,
2371
2380
getSynthesizedClone ( property . name ) ,
2372
2381
/*location*/ property
2373
2382
) ;
2383
+ if ( startsOnNewLine ) {
2384
+ expression . startsOnNewLine = true ;
2385
+ }
2386
+ return expression ;
2374
2387
}
2375
2388
2376
2389
/**
@@ -2380,15 +2393,19 @@ namespace ts {
2380
2393
* @param method The MethodDeclaration node.
2381
2394
* @param receiver The receiver for the assignment.
2382
2395
*/
2383
- function transformObjectLiteralMethodDeclarationToExpression ( node : ObjectLiteralExpression , method : MethodDeclaration , receiver : Expression ) {
2384
- return createAssignment (
2396
+ function transformObjectLiteralMethodDeclarationToExpression ( node : ObjectLiteralExpression , method : MethodDeclaration , receiver : Expression , startsOnNewLine : boolean ) {
2397
+ const expression = createAssignment (
2385
2398
createMemberAccessForPropertyName (
2386
2399
receiver ,
2387
2400
visitNode ( method . name , visitor , isPropertyName )
2388
2401
) ,
2389
2402
transformFunctionLikeToExpression ( method , /*location*/ method , /*name*/ undefined ) ,
2390
2403
/*location*/ method
2391
2404
) ;
2405
+ if ( startsOnNewLine ) {
2406
+ expression . startsOnNewLine = true ;
2407
+ }
2408
+ return expression ;
2392
2409
}
2393
2410
2394
2411
/**
0 commit comments