Skip to content

Commit 82b78d8

Browse files
committed
Merge pull request #4303 from SaschaNaz/fixClassExpressionFormatting
Fix formatting for class expression + expressionWithTypeArguments
2 parents f92aa86 + f832bd2 commit 82b78d8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/services/formatting/rules.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ namespace ts.formatting {
715715
case SyntaxKind.TypeReference:
716716
case SyntaxKind.TypeAssertionExpression:
717717
case SyntaxKind.ClassDeclaration:
718+
case SyntaxKind.ClassExpression:
718719
case SyntaxKind.InterfaceDeclaration:
719720
case SyntaxKind.FunctionDeclaration:
720721
case SyntaxKind.FunctionExpression:
@@ -725,6 +726,7 @@ namespace ts.formatting {
725726
case SyntaxKind.ConstructSignature:
726727
case SyntaxKind.CallExpression:
727728
case SyntaxKind.NewExpression:
729+
case SyntaxKind.ExpressionWithTypeArguments:
728730
return true;
729731
default:
730732
return false;

tests/cases/fourslash/genericsFormatting.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
////
1515
////foo()<number, string, T >();
1616
////(a + b)<number, string, T >();
17+
////
18+
////function bar<T>() {
19+
/////*inClassExpression*/ return class < T2 > {
20+
//// }
21+
////}
22+
/////*expressionWithTypeArguments*/class A < T > extends bar < T >( ) < T > {
23+
////}
1724

1825

1926
format.document();
@@ -33,4 +40,10 @@ goTo.marker("inNewSignature");
3340
verify.currentLineContentIs(" new <T>(a: T);");
3441

3542
goTo.marker("inOptionalMethodSignature");
36-
verify.currentLineContentIs(" op?<T, M>(a: T, b: M);");
43+
verify.currentLineContentIs(" op?<T, M>(a: T, b: M);");
44+
45+
goTo.marker("inClassExpression");
46+
verify.currentLineContentIs(" return class <T2> {");
47+
48+
goTo.marker("expressionWithTypeArguments");
49+
verify.currentLineContentIs("class A<T> extends bar<T>()<T> {");

0 commit comments

Comments
 (0)