Skip to content

Commit 04eb5bd

Browse files
authored
Fix build error where aliasing argument to _ in make function with jsx v4 (#5881)
* add test * fix alias props to any case in jsx v4 * changelog
1 parent d7b14d6 commit 04eb5bd

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ These are only breaking changes for unformatted code.
6262
#### :bug: Bug Fix
6363

6464
- Prevent inlining of async functions in additional cases https://github.com/rescript-lang/rescript-compiler/issues/5860
65+
- Fix build error where aliasing arguments to `_` in the make function with JSX V4. https://github.com/rescript-lang/rescript-compiler/pull/5881
6566

6667
# 10.1.0
6768

res_syntax/src/reactjs_jsx_v4.ml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,7 @@ let transformStructureItem ~config mapper item =
11031103
| Pexp_fun
11041104
( _arg_label,
11051105
_default,
1106-
{
1107-
ppat_desc =
1108-
Ppat_construct ({txt = Lident "()"}, _) | Ppat_any;
1109-
},
1106+
{ppat_desc = Ppat_construct ({txt = Lident "()"}, _)},
11101107
expr ) ->
11111108
(patternsWithLabel, patternsWithNolabel, expr)
11121109
| Pexp_fun
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@@jsxConfig({version: 4, mode: "automatic"})
2+
3+
module C0 = {
4+
@react.component
5+
let make = (~priority as _, ~text="Test") => React.string(text)
6+
}
7+
8+
module C1 = {
9+
@react.component
10+
let make = (~priority as p, ~text="Test") => React.string(p ++ text)
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@@jsxConfig({version: 4, mode: "automatic"})
2+
3+
module C0 = {
4+
type props<'priority, 'text> = {
5+
priority: 'priority,
6+
text?: 'text,
7+
}
8+
9+
@react.component
10+
let make = ({priority: _, ?text, _}: props<'priority, 'text>) => {
11+
let text = switch text {
12+
| Some(text) => text
13+
| None => "Test"
14+
}
15+
16+
React.string(text)
17+
}
18+
let make = {
19+
let \"AliasProps$C0" = (props: props<_>) => make(props)
20+
21+
\"AliasProps$C0"
22+
}
23+
}
24+
25+
module C1 = {
26+
type props<'priority, 'text> = {
27+
priority: 'priority,
28+
text?: 'text,
29+
}
30+
31+
@react.component
32+
let make = ({priority: p, ?text, _}: props<'priority, 'text>) => {
33+
let text = switch text {
34+
| Some(text) => text
35+
| None => "Test"
36+
}
37+
38+
React.string(p ++ text)
39+
}
40+
let make = {
41+
let \"AliasProps$C1" = (props: props<_>) => make(props)
42+
43+
\"AliasProps$C1"
44+
}
45+
}

0 commit comments

Comments
 (0)