diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 497c5114400..a5e37bf6902 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -715,6 +715,7 @@ namespace ts.formatting { case SyntaxKind.TypeReference: case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: @@ -725,6 +726,7 @@ namespace ts.formatting { case SyntaxKind.ConstructSignature: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: + case SyntaxKind.ExpressionWithTypeArguments: return true; default: return false; diff --git a/tests/cases/fourslash/genericsFormatting.ts b/tests/cases/fourslash/genericsFormatting.ts index b8ef27fa8f2..f5e44522a8e 100644 --- a/tests/cases/fourslash/genericsFormatting.ts +++ b/tests/cases/fourslash/genericsFormatting.ts @@ -14,6 +14,13 @@ //// ////foo()(); ////(a + b)(); +//// +////function bar() { +/////*inClassExpression*/ return class < T2 > { +//// } +////} +/////*expressionWithTypeArguments*/class A < T > extends bar < T >( ) < T > { +////} format.document(); @@ -33,4 +40,10 @@ goTo.marker("inNewSignature"); verify.currentLineContentIs(" new (a: T);"); goTo.marker("inOptionalMethodSignature"); -verify.currentLineContentIs(" op?(a: T, b: M);"); \ No newline at end of file +verify.currentLineContentIs(" op?(a: T, b: M);"); + +goTo.marker("inClassExpression"); +verify.currentLineContentIs(" return class {"); + +goTo.marker("expressionWithTypeArguments"); +verify.currentLineContentIs("class A extends bar() {"); \ No newline at end of file