diff --git a/CHANGELOG.md b/CHANGELOG.md index 3348d8c97f..d59aee1f22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ These are only breaking changes for unformatted code. #### :bug: Bug Fix - Prevent inlining of async functions in additional cases https://github.com/rescript-lang/rescript-compiler/issues/5860 +- Fix build error where aliasing arguments to `_` in the make function with JSX V4. https://github.com/rescript-lang/rescript-compiler/pull/5881 # 10.1.0 diff --git a/res_syntax/src/reactjs_jsx_v4.ml b/res_syntax/src/reactjs_jsx_v4.ml index b2f0747f3f..3492c335f3 100644 --- a/res_syntax/src/reactjs_jsx_v4.ml +++ b/res_syntax/src/reactjs_jsx_v4.ml @@ -1103,10 +1103,7 @@ let transformStructureItem ~config mapper item = | Pexp_fun ( _arg_label, _default, - { - ppat_desc = - Ppat_construct ({txt = Lident "()"}, _) | Ppat_any; - }, + {ppat_desc = Ppat_construct ({txt = Lident "()"}, _)}, expr ) -> (patternsWithLabel, patternsWithNolabel, expr) | Pexp_fun diff --git a/res_syntax/tests/ppx/react/aliasProps.res b/res_syntax/tests/ppx/react/aliasProps.res new file mode 100644 index 0000000000..71734f50ca --- /dev/null +++ b/res_syntax/tests/ppx/react/aliasProps.res @@ -0,0 +1,11 @@ +@@jsxConfig({version: 4, mode: "automatic"}) + +module C0 = { + @react.component + let make = (~priority as _, ~text="Test") => React.string(text) +} + +module C1 = { + @react.component + let make = (~priority as p, ~text="Test") => React.string(p ++ text) +} diff --git a/res_syntax/tests/ppx/react/expected/aliasProps.res.txt b/res_syntax/tests/ppx/react/expected/aliasProps.res.txt new file mode 100644 index 0000000000..d99b8e2209 --- /dev/null +++ b/res_syntax/tests/ppx/react/expected/aliasProps.res.txt @@ -0,0 +1,45 @@ +@@jsxConfig({version: 4, mode: "automatic"}) + +module C0 = { + type props<'priority, 'text> = { + priority: 'priority, + text?: 'text, + } + + @react.component + let make = ({priority: _, ?text, _}: props<'priority, 'text>) => { + let text = switch text { + | Some(text) => text + | None => "Test" + } + + React.string(text) + } + let make = { + let \"AliasProps$C0" = (props: props<_>) => make(props) + + \"AliasProps$C0" + } +} + +module C1 = { + type props<'priority, 'text> = { + priority: 'priority, + text?: 'text, + } + + @react.component + let make = ({priority: p, ?text, _}: props<'priority, 'text>) => { + let text = switch text { + | Some(text) => text + | None => "Test" + } + + React.string(p ++ text) + } + let make = { + let \"AliasProps$C1" = (props: props<_>) => make(props) + + \"AliasProps$C1" + } +}