File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -469,7 +469,9 @@ namespace ts.formatting {
469469 }
470470
471471 function isBraceWrappedContext ( context : FormattingContext ) : boolean {
472- return context . contextNode . kind === SyntaxKind . ObjectBindingPattern || isSingleLineBlockContext ( context ) ;
472+ return context . contextNode . kind === SyntaxKind . ObjectBindingPattern ||
473+ context . contextNode . kind === SyntaxKind . MappedType ||
474+ isSingleLineBlockContext ( context ) ;
473475 }
474476
475477 // This check is done before an open brace in a control construct, a function, or a typescript block declaration
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ /////*x1*/type x1<T> = {[K in keyof T]: number}
4+ /////*x2*/type x2<T> = { [K in keyof T]: number }
5+ /////*x3*/type x3<T> = { [K in keyof T]: number}
6+ /////*x4*/type x4<T> = {[K in keyof T]: number }
7+ /////*x5*/type x5<T> = { [K in keyof T]: number}
8+ /////*x6*/type x6<T> = {[K in keyof T]: number }
9+ /////*x7*/type x7<T> = { [K in keyof T]: number }
10+ /////*x8*/type x8<T> = { [K in keyof T]: number };
11+ ////
12+ /////*y1*/type y1 = {foo: number}
13+ /////*y2*/type y2 = { foo: number }
14+ /////*y3*/type y3 = { foo: number}
15+ /////*y4*/type y4 = {foo: number }
16+ /////*y5*/type y5 = { foo: number}
17+ /////*y6*/type y6 = {foo: number }
18+ /////*y7*/type y7 = { foo: number }
19+ /////*y8*/type y8 = { foo: number };
20+
21+ format . document ( ) ;
22+ for ( let index = 1 ; index < 8 ; index ++ ) {
23+ goTo . marker ( `x${ index } ` ) ;
24+ verify . currentLineContentIs ( `type x${ index } <T> = { [K in keyof T]: number }` ) ;
25+ }
26+
27+ goTo . marker ( `x8` ) ;
28+ verify . currentLineContentIs ( `type x8<T> = { [K in keyof T]: number };` ) ;
29+
30+ for ( let index = 1 ; index < 8 ; index ++ ) {
31+ goTo . marker ( `y${ index } ` ) ;
32+ verify . currentLineContentIs ( `type y${ index } = { foo: number }` ) ;
33+ }
34+
35+ goTo . marker ( `y8` ) ;
36+ verify . currentLineContentIs ( `type y8 = { foo: number };` ) ;
You can’t perform that action at this time.
0 commit comments