Skip to content

Commit 5dedbc1

Browse files
committed
Fix gentype jsx issue
Fixes #7103 The Jsx.element type has moved from Pervasives.
1 parent 49bcc32 commit 5dedbc1

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- Fix JSX settings inheritance: only 'version' propagates to dependencies, preserving their 'mode' and 'module'. https://github.com/rescript-lang/rescript-compiler/pull/7094
3636
- Fix variant cast to int. https://github.com/rescript-lang/rescript-compiler/pull/7058
3737
- Fix comments formatted away in function without arguments. https://github.com/rescript-lang/rescript-compiler/pull/7095
38+
- Fix genType JSX component compilation. https://github.com/rescript-lang/rescript-compiler/pull/7103
3839

3940
#### :nail_care: Polish
4041

compiler/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
207207
{dependencies = []; type_ = EmitType.type_react_event_mouse_t}
208208
| ( ( ["React"; "element"]
209209
| ["ReasonReact"; "reactElement"]
210-
| ["Pervasives"; "Jsx"; "element"] ),
210+
| ["Pervasives"; "Jsx"; "element"]
211+
| ["Jsx"; "element"] ),
211212
[] ) ->
212213
{dependencies = []; type_ = EmitType.type_react_element}
213214
| (["FB"; "option"] | ["option"]), [param_translation] ->

tests/gentype_tests/typescript-react-example/src/Hooks.gen.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import * as HooksJS from './Hooks.res.js';
77

88
import type {TypedArray2_Uint8Array_t as Js_TypedArray2_Uint8Array_t} from '../src/shims/Js.shim';
99

10-
import type {element as Jsx_element} from '../src/shims/Jsx.shim';
11-
1210
export type vehicle = { readonly name: string };
1311

1412
export type props<vehicle> = { readonly vehicle: vehicle };
@@ -57,21 +55,21 @@ export type WithChildren_props<vehicle,children> = { readonly vehicle: vehicle;
5755

5856
export type DD_props<array,name> = { readonly array: array; readonly name: name };
5957

60-
export const $$default: (_1:props<vehicle>) => Jsx_element = HooksJS.default as any;
58+
export const $$default: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.default as any;
6159

6260
export default $$default;
6361

64-
export const Another_anotherComponent: (_1:Another_props<vehicle,(() => void)>) => Jsx_element = HooksJS.Another.anotherComponent as any;
62+
export const Another_anotherComponent: React.ComponentType<{ readonly vehicle: vehicle; readonly callback: () => void }> = HooksJS.Another.anotherComponent as any;
6563

66-
export const Inner_make: (_1:Inner_props<vehicle>) => Jsx_element = HooksJS.Inner.make as any;
64+
export const Inner_make: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.Inner.make as any;
6765

68-
export const Inner_Another_anotherComponent: (_1:Inner_Another_props<vehicle>) => Jsx_element = HooksJS.Inner.Another.anotherComponent as any;
66+
export const Inner_Another_anotherComponent: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.Inner.Another.anotherComponent as any;
6967

70-
export const Inner_Inner2_make: (_1:Inner_Inner2_props<vehicle>) => Jsx_element = HooksJS.Inner.Inner2.make as any;
68+
export const Inner_Inner2_make: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.Inner.Inner2.make as any;
7169

72-
export const Inner_Inner2_Another_anotherComponent: (_1:Inner_Inner2_Another_props<vehicle>) => Jsx_element = HooksJS.Inner.Inner2.Another.anotherComponent as any;
70+
export const Inner_Inner2_Another_anotherComponent: React.ComponentType<{ readonly vehicle: vehicle }> = HooksJS.Inner.Inner2.Another.anotherComponent as any;
7371

74-
export const NoProps_make: (_1:NoProps_props) => Jsx_element = HooksJS.NoProps.make as any;
72+
export const NoProps_make: React.ComponentType<{}> = HooksJS.NoProps.make as any;
7573

7674
export const functionWithRenamedArgs: (_to:vehicle, _Type:vehicle, cb:cb) => string = HooksJS.functionWithRenamedArgs as any;
7775

@@ -93,23 +91,31 @@ export const Fun_functionReturningReactElement: React.ComponentType<{ readonly n
9391

9492
export const RenderPropRequiresConversion_make: React.ComponentType<{ readonly renderVehicle: React.ComponentType<{ readonly number: number; readonly vehicle: vehicle }> }> = HooksJS.RenderPropRequiresConversion.make as any;
9593

96-
export const WithChildren_aComponentWithChildren: (_1:WithChildren_props<vehicle,JSX.Element>) => Jsx_element = HooksJS.WithChildren.aComponentWithChildren as any;
94+
export const WithChildren_aComponentWithChildren: React.ComponentType<{ readonly vehicle: vehicle; readonly children: React.ReactNode }> = HooksJS.WithChildren.aComponentWithChildren as any;
9795

9896
export const DD_make: React.ComponentType<{ readonly array: Js_TypedArray2_Uint8Array_t; readonly name: string }> = HooksJS.DD.make as any;
9997

100-
export const NoProps: { make: (_1:NoProps_props) => Jsx_element } = HooksJS.NoProps as any;
98+
export const NoProps: { make: React.ComponentType<{}> } = HooksJS.NoProps as any;
10199

102100
export const Inner: {
103101
Inner2: {
104102
Another: {
105-
anotherComponent: (_1:Inner_Inner2_Another_props<vehicle>) => Jsx_element
103+
anotherComponent: React.ComponentType<{
104+
readonly vehicle: vehicle
105+
}>
106106
};
107-
make: (_1:Inner_Inner2_props<vehicle>) => Jsx_element
107+
make: React.ComponentType<{
108+
readonly vehicle: vehicle
109+
}>
108110
};
109111
Another: {
110-
anotherComponent: (_1:Inner_Another_props<vehicle>) => Jsx_element
112+
anotherComponent: React.ComponentType<{
113+
readonly vehicle: vehicle
114+
}>
111115
};
112-
make: (_1:Inner_props<vehicle>) => Jsx_element
116+
make: React.ComponentType<{
117+
readonly vehicle: vehicle
118+
}>
113119
} = HooksJS.Inner as any;
114120

115121
export const RenderPropRequiresConversion: { make: React.ComponentType<{ readonly renderVehicle: React.ComponentType<{ readonly number: number; readonly vehicle: vehicle }> }> } = HooksJS.RenderPropRequiresConversion as any;
@@ -126,10 +132,10 @@ export const Fun: { functionReturningReactElement: React.ComponentType<{ readonl
126132

127133
export const WithRef: { makeWithRef: (_1:WithRef_props<vehicle>) => (_1:(null | undefined | any)) => JSX.Element } = HooksJS.WithRef as any;
128134

129-
export const WithChildren: { aComponentWithChildren: (_1:WithChildren_props<vehicle,JSX.Element>) => Jsx_element } = HooksJS.WithChildren as any;
135+
export const WithChildren: { aComponentWithChildren: React.ComponentType<{ readonly vehicle: vehicle; readonly children: React.ReactNode }> } = HooksJS.WithChildren as any;
130136

131137
export const DD: { make: React.ComponentType<{ readonly array: Js_TypedArray2_Uint8Array_t; readonly name: string }> } = HooksJS.DD as any;
132138

133-
export const Another: { anotherComponent: (_1:Another_props<vehicle,(() => void)>) => Jsx_element } = HooksJS.Another as any;
139+
export const Another: { anotherComponent: React.ComponentType<{ readonly vehicle: vehicle; readonly callback: () => void }> } = HooksJS.Another as any;
134140

135141
export const Poly: { polymorphicComponent: React.ComponentType<{ readonly p: [vehicle, any] }> } = HooksJS.Poly as any;

tests/gentype_tests/typescript-react-example/src/OnClick2.gen.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import * as OnClick2JS from './OnClick2.res.js';
77

88
import type {Mouse_t as JsxEvent_Mouse_t} from '../src/shims/JsxEvent.shim';
99

10-
import type {element as Jsx_element} from '../src/shims/Jsx.shim';
11-
1210
export type props<onClick> = { readonly onClick: onClick };
1311

14-
export const make: (_1:props<((_1:JsxEvent_Mouse_t) => void)>) => Jsx_element = OnClick2JS.make as any;
12+
export const make: React.ComponentType<{ readonly onClick: (_1:JsxEvent_Mouse_t) => void }> = OnClick2JS.make as any;

0 commit comments

Comments
 (0)