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

Add the missing loc of jsx call expression #730

Merged
merged 4 commits into from
Jan 30, 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 @@ -56,6 +56,7 @@
- Fix parsing of spread props as an expression in JSX V4 https://github.com/rescript-lang/syntax/pull/721
- Fix dropping attributes from props in make function in JSX V4 https://github.com/rescript-lang/syntax/pull/723
- Fix an issue where error messages related to duplicate props were displayed without a loc and were unclear https://github.com/rescript-lang/syntax/pull/728
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730

#### :eyeglasses: Spec Compliance

Expand Down
13 changes: 7 additions & 6 deletions cli/reactjs_jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,25 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
| _ -> (
match (!childrenArg, keyProp) with
| None, key :: _ ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "JsxPPXReactSupport", "createElementWithKey");
})
[key; (nolabel, makeID); (nolabel, props)]
| None, [] ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
[(nolabel, makeID); (nolabel, props)]
| Some children, key :: _ ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
Expand All @@ -463,7 +464,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
})
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
| Some children, [] ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
Expand Down Expand Up @@ -544,7 +545,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
| _ ->
let children, nonChildrenProps =
Expand Down
1 change: 1 addition & 0 deletions tests/ppx/react/expected/forwardRef.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ module V4A = {
@react.component
let make = (_: props) => {
let input = React.useRef(Js.Nullable.null)

ReactDOM.jsx(
"div",
{
Expand Down