diff --git a/CHANGELOG.md b/CHANGELOG.md index d8550e2809..3b7daea7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,8 +38,7 @@ These are only breaking changes for unformatted code. - Syntax: process uncurried types explicitly in the parser/printer https://github.com/rescript-lang/rescript-compiler/pull/5784 - Syntax: process uncurried function declarations explicitly in the parser/printer https://github.com/rescript-lang/rescript-compiler/pull/5794 -- PPX V4: allow uncurried `make` function and treat it like a curried one https://github.com/rescript-lang/rescript-compiler/pull/5802 -- PPX V4: allow uncurried `make` function with nolabel arguments e.g. `forwardRef` component https://github.com/rescript-lang/rescript-compiler/pull/5808 +- PPX V4: allow uncurried `make` function and treat it like a curried one [#5802](https://github.com/rescript-lang/rescript-compiler/pull/5802) [#5808](https://github.com/rescript-lang/rescript-compiler/pull/5808) [#5812](https://github.com/rescript-lang/rescript-compiler/pull/5812) # 10.1.0-rc.5 diff --git a/res_syntax/cli/reactjs_jsx_v4.ml b/res_syntax/cli/reactjs_jsx_v4.ml index 3fa3cd3a30..8ed92b7df4 100644 --- a/res_syntax/cli/reactjs_jsx_v4.ml +++ b/res_syntax/cli/reactjs_jsx_v4.ml @@ -751,6 +751,11 @@ let transformStructureItem ~config mapper item = config.hasReactComponent <- true; check_string_int_attribute_iter.structure_item check_string_int_attribute_iter item; + let pval_type = + match pval_type.ptyp_desc with + | Ptyp_constr ({txt = Ldot (Ldot (Lident "Js", "Fn"), _)}, [t]) -> t + | _ -> pval_type + in let coreTypeOfAttr = React_jsx_common.coreTypeOfAttrs pval_attributes in let typVarsOfCoreType = coreTypeOfAttr diff --git a/res_syntax/tests/ppx/react/expected/v4.res.txt b/res_syntax/tests/ppx/react/expected/v4.res.txt index 0a56293ff2..a705527ae6 100644 --- a/res_syntax/tests/ppx/react/expected/v4.res.txt +++ b/res_syntax/tests/ppx/react/expected/v4.res.txt @@ -42,3 +42,19 @@ module type TUncurried = { let make: React.componentLike, React.element> } + +module E = { + type props<'x> = { + x: 'x, + } + + external make: React.componentLike, React.element> = "default" +} + +module EUncurried = { + type props<'x> = { + x: 'x, + } + + external make: React.componentLike, React.element> = "default" +} diff --git a/res_syntax/tests/ppx/react/v4.res b/res_syntax/tests/ppx/react/v4.res index 227b8f888c..f95be87197 100644 --- a/res_syntax/tests/ppx/react/v4.res +++ b/res_syntax/tests/ppx/react/v4.res @@ -17,3 +17,13 @@ module type TUncurried = { @react.component let make: (. ~x: string) => React.element } + +module E = { + @react.component + external make: (~x: string) => React.element = "default" +} + +module EUncurried = { + @react.component + external make: (. ~x: string) => React.element = "default" +}