File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
tests/build_tests/super_errors Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 32
32
- Fix exponential notation syntax. https://github.com/rescript-lang/rescript/pull/7174
33
33
- Fix bug where a ref assignment is moved ouside a conditional. https://github.com/rescript-lang/rescript/pull/7176
34
34
- Fix nullable to opt conversion. https://github.com/rescript-lang/rescript/pull/7193
35
+ - Raise error when defining external React components with ` @react.componentWithProps ` . https://github.com/rescript-lang/rescript/pull/7217
35
36
36
37
#### :house : Internal
37
38
Original file line number Diff line number Diff line change @@ -1286,9 +1286,21 @@ let transform_structure_item ~config item =
1286
1286
pstr_desc =
1287
1287
Pstr_primitive ({pval_attributes; pval_type} as value_description);
1288
1288
} as pstr -> (
1289
- match List. filter Jsx_common. has_attr pval_attributes with
1290
- | [] -> [item]
1291
- | [_] ->
1289
+ match
1290
+ ( List. filter Jsx_common. has_attr pval_attributes,
1291
+ List. filter Jsx_common. has_attr_with_props pval_attributes )
1292
+ with
1293
+ | [] , [] -> [item]
1294
+ | _ , [_] ->
1295
+ Jsx_common. raise_error ~loc: pstr_loc
1296
+ " Components cannot be defined as externals when using \
1297
+ @react.componentWithProps.\n\n \
1298
+ If you intended to define an external for a React component using a \
1299
+ props type,\n \
1300
+ use the type React.component<props> instead.\n \
1301
+ Alternatively, use @react.component for an external definition with \
1302
+ labeled arguments."
1303
+ | [_], [] ->
1292
1304
check_multiple_components ~config ~loc: pstr_loc;
1293
1305
check_string_int_attribute_iter.structure_item
1294
1306
check_string_int_attribute_iter item;
Original file line number Diff line number Diff line change
1
+
2
+ [1;31mWe've found a bug for you![0m
3
+ [36m/.../fixtures/react_component_with_props_external.res[0m:[2m1:1-2:40[0m
4
+
5
+ [1;31m1[0m [2m│[0m [1;31m@react.componentWithProps[0m
6
+ [1;31m2[0m [2m│[0m [1;31mexternal make: React.element = "default"[0m
7
+ 3 [2m│[0m
8
+
9
+ Components cannot be defined as externals when using @react.componentWithProps.
10
+
11
+ If you intended to define an external for a React component using a props type,
12
+ use the type React.component<props> instead.
13
+ Alternatively, use @react.component for an external definition with labeled arguments.
Original file line number Diff line number Diff line change
1
+ @react.componentWithProps
2
+ external make : React .element = "default"
You can’t perform that action at this time.
0 commit comments