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 3232- Fix exponential notation syntax. https://github.com/rescript-lang/rescript/pull/7174
3333- Fix bug where a ref assignment is moved ouside a conditional. https://github.com/rescript-lang/rescript/pull/7176
3434- 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
3536
3637#### :house : Internal
3738
Original file line number Diff line number Diff line change @@ -1286,9 +1286,21 @@ let transform_structure_item ~config item =
12861286 pstr_desc =
12871287 Pstr_primitive ({pval_attributes; pval_type} as value_description);
12881288 } 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+ | [_], [] ->
12921304 check_multiple_components ~config ~loc: pstr_loc;
12931305 check_string_int_attribute_iter.structure_item
12941306 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