Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 52cfbb3

Browse files
authored
Fix formatting of props spread for multiline JSX expression (#736)
1 parent 52d508f commit 52cfbb3

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- Fix issue with overlapping labelled argument with default value https://github.com/rescript-lang/syntax/pull/734
6464
- Fix issue with using alias and default value together https://github.com/rescript-lang/syntax/pull/734
6565
- Fix formatting of `switch` expressions that contain braced `cases` inside https://github.com/rescript-lang/syntax/pull/735
66+
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/syntax/pull/736
6667

6768
#### :eyeglasses: Spec Compliance
6869

src/res_printer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,7 +4337,7 @@ and printJsxProp ~customLayout arg cmtTbl =
43374337
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
43384338
| Asttypes.Labelled "_spreadProps", expr ->
43394339
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
4340-
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
4340+
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
43414341
| lbl, expr ->
43424342
let argLoc, expr =
43434343
match expr.pexp_attributes with

tests/printer/expr/expected/jsx.res.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,10 @@ let v =
410410
</A>
411411

412412
let x = <A x="y" {...str} />
413+
414+
// https://github.com/rescript-lang/rescript-compiler/issues/6002
415+
let x = props =>
416+
<A
417+
{...props}
418+
className="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight"
419+
/>

tests/printer/expr/jsx.res

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,11 @@ let v =
402402
</B>
403403
</A>
404404

405-
let x = <A x="y" {...str} />
405+
let x = <A x="y" {...str} />
406+
407+
// https://github.com/rescript-lang/rescript-compiler/issues/6002
408+
let x = props =>
409+
<A
410+
{...props}
411+
className="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight"
412+
/>

0 commit comments

Comments
 (0)