Skip to content

Commit 2cd2228

Browse files
ah-yuZhang, Zheyu
and
Zhang, Zheyu
authored
Fix formatting of props spread for multiline JSX expression (#6006)
* fix formatting of jsx spread props * format * update CHANGELOG --------- Co-authored-by: Zhang, Zheyu <[email protected]>
1 parent 457aeff commit 2cd2228

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 @@ These are only breaking changes for unformatted code.
6363
- Fix issue with using alias and default value together https://github.com/rescript-lang/rescript-compiler/pull/5989
6464
- GenType: fix issue with V3 compatibility mode (see https://github.com/rescript-lang/rescript-compiler/issues/5990) https://github.com/rescript-lang/rescript-compiler/pull/5991
6565
- Fix issue in `Js.Promise2` where `then` and `catch` were returning `undefined` https://github.com/rescript-lang/rescript-compiler/pull/5997
66+
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/rescript-compiler/pull/6006
6667

6768
#### :nail_care: Polish
6869

res_syntax/src/res_printer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4264,7 +4264,7 @@ and printJsxProp ~state arg cmtTbl =
42644264
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
42654265
| Asttypes.Labelled "_spreadProps", expr ->
42664266
let doc = printExpressionWithComments ~state expr cmtTbl in
4267-
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
4267+
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
42684268
| lbl, expr ->
42694269
let argLoc, expr =
42704270
match expr.pexp_attributes with

res_syntax/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+
/>

res_syntax/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)