Skip to content

Commit 67eabb9

Browse files
HerringtonDarkholmemhegazy
authored andcommitted
fix microsoft#20449, insert space between decorators (microsoft#20491)
1 parent 7ef541c commit 67eabb9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/services/formatting/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace ts.formatting {
198198
RuleAction.Delete),
199199

200200
// decorators
201-
rule("SpaceBeforeAt", anyToken, SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.Space),
201+
rule("SpaceBeforeAt", [SyntaxKind.CloseParenToken, SyntaxKind.Identifier], SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.Space),
202202
rule("NoSpaceAfterAt", SyntaxKind.AtToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Delete),
203203
// Insert space after @ in decorator
204204
rule("SpaceAfterDecorator",

tests/cases/fourslash/formattingDecorators.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
/////*29*/ property1;
4242
////
4343
/////*30*/ @ decorator33 @ decorator34 @decorator35 property2;
44+
/////*31*/function test(@decorator36@decorator37 param) {};
45+
/////*32*/function test2(@decorator38()@decorator39()param) {};
4446
////}
4547

4648
format.document();
@@ -103,4 +105,8 @@ verify.currentLineContentIs(" @decorator32");
103105
goTo.marker("29");
104106
verify.currentLineContentIs(" property1;");
105107
goTo.marker("30");
106-
verify.currentLineContentIs(" @decorator33 @decorator34 @decorator35 property2;");
108+
verify.currentLineContentIs(" @decorator33 @decorator34 @decorator35 property2;");
109+
goTo.marker("31");
110+
verify.currentLineContentIs("function test(@decorator36 @decorator37 param) { };");
111+
goTo.marker("32");
112+
verify.currentLineContentIs("function test2(@decorator38() @decorator39() param) { };");

0 commit comments

Comments
 (0)