Skip to content
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

Fix the external uncurried make function support for JSX V4 #5812

Merged
merged 3 commits into from
Nov 16, 2022
Merged
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
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions res_syntax/cli/reactjs_jsx_v4.ml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions res_syntax/tests/ppx/react/expected/v4.res.txt
Original file line number Diff line number Diff line change
@@ -42,3 +42,19 @@ module type TUncurried = {

let make: React.componentLike<props<string>, React.element>
}

module E = {
type props<'x> = {
x: 'x,
}

external make: React.componentLike<props<string>, React.element> = "default"
}

module EUncurried = {
type props<'x> = {
x: 'x,
}

external make: React.componentLike<props<string>, React.element> = "default"
}
10 changes: 10 additions & 0 deletions res_syntax/tests/ppx/react/v4.res
Original file line number Diff line number Diff line change
@@ -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"
}