From 3ccd4e76fc026605b056a4917f24bb3b75e28873 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Wed, 16 Nov 2022 09:11:10 +0900 Subject: [PATCH 1/3] add test to fix uncurried external make for jsx v4 --- res_syntax/tests/ppx/react/expected/v4.res.txt | 14 ++++++++++++++ res_syntax/tests/ppx/react/v4.res | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/res_syntax/tests/ppx/react/expected/v4.res.txt b/res_syntax/tests/ppx/react/expected/v4.res.txt index 0a56293ff2..ad4a2aa645 100644 --- a/res_syntax/tests/ppx/react/expected/v4.res.txt +++ b/res_syntax/tests/ppx/react/expected/v4.res.txt @@ -42,3 +42,17 @@ 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 = {} + + 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" +} From e366d24cd44fb28ad9163f5ab95e84ddc926cc2b Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Wed, 16 Nov 2022 09:19:45 +0900 Subject: [PATCH 2/3] fix uncurried external make for jsx v4 --- res_syntax/cli/reactjs_jsx_v4.ml | 5 +++++ res_syntax/tests/ppx/react/expected/v4.res.txt | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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 ad4a2aa645..a705527ae6 100644 --- a/res_syntax/tests/ppx/react/expected/v4.res.txt +++ b/res_syntax/tests/ppx/react/expected/v4.res.txt @@ -52,7 +52,9 @@ module E = { } module EUncurried = { - type props = {} + type props<'x> = { + x: 'x, + } - external make: React.componentLike React.element> = "default" + external make: React.componentLike, React.element> = "default" } From f370eef63eab75a555df312abccad977dc968fb2 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Wed, 16 Nov 2022 09:23:38 +0900 Subject: [PATCH 3/3] cleanup changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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