Skip to content

Fix formatting of props spread for multiline JSX expression #6006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ These are only breaking changes for unformatted code.
- Fix issue with using alias and default value together https://github.com/rescript-lang/rescript-compiler/pull/5989
- 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
- Fix issue in `Js.Promise2` where `then` and `catch` were returning `undefined` https://github.com/rescript-lang/rescript-compiler/pull/5997
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/rescript-compiler/pull/6006

#### :nail_care: Polish

Expand Down
2 changes: 1 addition & 1 deletion res_syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4264,7 +4264,7 @@ and printJsxProp ~state arg cmtTbl =
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
| Asttypes.Labelled "_spreadProps", expr ->
let doc = printExpressionWithComments ~state expr cmtTbl in
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
| lbl, expr ->
let argLoc, expr =
match expr.pexp_attributes with
Expand Down
7 changes: 7 additions & 0 deletions res_syntax/tests/printer/expr/expected/jsx.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,10 @@ let v =
</A>

let x = <A x="y" {...str} />

// https://github.com/rescript-lang/rescript-compiler/issues/6002
let x = props =>
<A
{...props}
className="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight"
/>
9 changes: 8 additions & 1 deletion res_syntax/tests/printer/expr/jsx.res
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,11 @@ let v =
</B>
</A>

let x = <A x="y" {...str} />
let x = <A x="y" {...str} />

// https://github.com/rescript-lang/rescript-compiler/issues/6002
let x = props =>
<A
{...props}
className="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium text-xs leading-tight"
/>