@@ -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,28 @@ 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
+ expressions . push (
1903
+ startOnNewLine (
1904
+ createAssignment (
1905
+ temp ,
1906
+ setNodeEmitFlags (
1907
+ createObjectLiteral (
1908
+ visitNodes ( properties , visitor , isObjectLiteralElement , 0 , numInitialProperties ) ,
1909
+ /*location*/ undefined ,
1910
+ node . multiLine
1911
+ ) ,
1912
+ NodeEmitFlags . Indented
1913
+ )
1914
+ ) ,
1915
+ node . multiLine
1916
+ )
1911
1917
) ;
1912
1918
1913
1919
addObjectLiteralMembers ( expressions , node , temp , numInitialProperties ) ;
1914
1920
1915
1921
// We need to clone the temporary identifier so that we can write it on a
1916
1922
// new line
1917
- addNode ( expressions , getMutableClone ( temp ) , node . multiLine ) ;
1923
+ expressions . push ( startOnNewLine ( getMutableClone ( temp ) , node . multiLine ) ) ;
1918
1924
return inlineExpressions ( expressions ) ;
1919
1925
}
1920
1926
@@ -2313,21 +2319,21 @@ namespace ts {
2313
2319
case SyntaxKind . SetAccessor :
2314
2320
const accessors = getAllAccessorDeclarations ( node . properties , < AccessorDeclaration > property ) ;
2315
2321
if ( property === accessors . firstAccessor ) {
2316
- addNode ( expressions , transformAccessorsToExpression ( receiver , accessors ) , node . multiLine ) ;
2322
+ expressions . push ( transformAccessorsToExpression ( receiver , accessors , node . multiLine ) ) ;
2317
2323
}
2318
2324
2319
2325
break ;
2320
2326
2321
2327
case SyntaxKind . PropertyAssignment :
2322
- addNode ( expressions , transformPropertyAssignmentToExpression ( node , < PropertyAssignment > property , receiver ) , node . multiLine ) ;
2328
+ expressions . push ( transformPropertyAssignmentToExpression ( node , < PropertyAssignment > property , receiver , node . multiLine ) ) ;
2323
2329
break ;
2324
2330
2325
2331
case SyntaxKind . ShorthandPropertyAssignment :
2326
- addNode ( expressions , transformShorthandPropertyAssignmentToExpression ( node , < ShorthandPropertyAssignment > property , receiver ) , node . multiLine ) ;
2332
+ expressions . push ( transformShorthandPropertyAssignmentToExpression ( node , < ShorthandPropertyAssignment > property , receiver , node . multiLine ) ) ;
2327
2333
break ;
2328
2334
2329
2335
case SyntaxKind . MethodDeclaration :
2330
- addNode ( expressions , transformObjectLiteralMethodDeclarationToExpression ( node , < MethodDeclaration > property , receiver ) , node . multiLine ) ;
2336
+ expressions . push ( transformObjectLiteralMethodDeclarationToExpression ( node , < MethodDeclaration > property , receiver , node . multiLine ) ) ;
2331
2337
break ;
2332
2338
2333
2339
default :
@@ -2344,15 +2350,19 @@ namespace ts {
2344
2350
* @param property The PropertyAssignment node.
2345
2351
* @param receiver The receiver for the assignment.
2346
2352
*/
2347
- function transformPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : PropertyAssignment , receiver : Expression ) {
2348
- return createAssignment (
2353
+ function transformPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : PropertyAssignment , receiver : Expression , startsOnNewLine : boolean ) {
2354
+ const expression = createAssignment (
2349
2355
createMemberAccessForPropertyName (
2350
2356
receiver ,
2351
2357
visitNode ( property . name , visitor , isPropertyName )
2352
2358
) ,
2353
2359
visitNode ( property . initializer , visitor , isExpression ) ,
2354
2360
/*location*/ property
2355
2361
) ;
2362
+ if ( startsOnNewLine ) {
2363
+ expression . startsOnNewLine = true ;
2364
+ }
2365
+ return expression ;
2356
2366
}
2357
2367
2358
2368
/**
@@ -2362,15 +2372,19 @@ namespace ts {
2362
2372
* @param property The ShorthandPropertyAssignment node.
2363
2373
* @param receiver The receiver for the assignment.
2364
2374
*/
2365
- function transformShorthandPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : ShorthandPropertyAssignment , receiver : Expression ) {
2366
- return createAssignment (
2375
+ function transformShorthandPropertyAssignmentToExpression ( node : ObjectLiteralExpression , property : ShorthandPropertyAssignment , receiver : Expression , startsOnNewLine : boolean ) {
2376
+ const expression = createAssignment (
2367
2377
createMemberAccessForPropertyName (
2368
2378
receiver ,
2369
2379
visitNode ( property . name , visitor , isPropertyName )
2370
2380
) ,
2371
2381
getSynthesizedClone ( property . name ) ,
2372
2382
/*location*/ property
2373
2383
) ;
2384
+ if ( startsOnNewLine ) {
2385
+ expression . startsOnNewLine = true ;
2386
+ }
2387
+ return expression ;
2374
2388
}
2375
2389
2376
2390
/**
@@ -2380,15 +2394,19 @@ namespace ts {
2380
2394
* @param method The MethodDeclaration node.
2381
2395
* @param receiver The receiver for the assignment.
2382
2396
*/
2383
- function transformObjectLiteralMethodDeclarationToExpression ( node : ObjectLiteralExpression , method : MethodDeclaration , receiver : Expression ) {
2384
- return createAssignment (
2397
+ function transformObjectLiteralMethodDeclarationToExpression ( node : ObjectLiteralExpression , method : MethodDeclaration , receiver : Expression , startsOnNewLine : boolean ) {
2398
+ const expression = createAssignment (
2385
2399
createMemberAccessForPropertyName (
2386
2400
receiver ,
2387
2401
visitNode ( method . name , visitor , isPropertyName )
2388
2402
) ,
2389
2403
transformFunctionLikeToExpression ( method , /*location*/ method , /*name*/ undefined ) ,
2390
2404
/*location*/ method
2391
2405
) ;
2406
+ if ( startsOnNewLine ) {
2407
+ expression . startsOnNewLine = true ;
2408
+ }
2409
+ return expression ;
2392
2410
}
2393
2411
2394
2412
/**
0 commit comments