Skip to content

Commit 72750a9

Browse files
authored
JSX PPX: externals: React.componentLike -> React.component (#7952)
* JSX PPX: externals: React.componentLike -> React.component * Analysis test output * CHANGELOG
1 parent 26fa42a commit 72750a9

16 files changed

+40
-52
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#### :house: Internal
3131

32+
- JSX PPX: use `React.component` instead of `React.componentLike` for externals. https://github.com/rescript-lang/rescript/pull/7952
33+
3234
# 12.0.0-rc.1
3335

3436
#### :nail_care: Polish

compiler/syntax/src/jsx_v4.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@ let transform_structure_item ~config item =
990990
(* can't be an arrow because it will defensively uncurry *)
991991
let new_external_type =
992992
Ptyp_constr
993-
( {loc = pstr_loc; txt = module_access_name config "componentLike"},
994-
[ret_props_type; jsx_element_type config ~loc:pstr_loc] )
993+
( {loc = pstr_loc; txt = module_access_name config "component"},
994+
[ret_props_type] )
995995
in
996996
let new_structure =
997997
{
@@ -1079,8 +1079,8 @@ let transform_signature_item ~config item =
10791079
(* can't be an arrow because it will defensively uncurry *)
10801080
let new_external_type =
10811081
Ptyp_constr
1082-
( {loc = psig_loc; txt = module_access_name config "componentLike"},
1083-
[ret_props_type; jsx_element_type config ~loc:psig_loc] )
1082+
( {loc = psig_loc; txt = module_access_name config "component"},
1083+
[ret_props_type] )
10841084
in
10851085
let new_structure =
10861086
{

tests/analysis_tests/tests/src/expected/Jsx2.resi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Hover src/Jsx2.resi 1:4
2-
{"contents": {"kind": "markdown", "value": "```rescript\nReact.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}}
2+
{"contents": {"kind": "markdown", "value": "```rescript\nprops<string>\n```\n\n---\n\n```\n \n```\n```rescript\ntype props<'first> = {first: 'first}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Jsx2.resi%22%2C0%2C0%5D)\n"}}
33

44
Hover src/Jsx2.resi 4:4
55
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}

tests/syntax_tests/data/ppx/react/expected/aliasProps.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ module C6 = {
121121
@res.jsxComponentProps
122122
type props = {}
123123

124-
let make: React.componentLike<props, React.element>
124+
let make: React.component<props>
125125
}
126126
@res.jsxComponentProps
127127
type props<'comp, 'x> = {comp: 'comp, x: 'x}

tests/syntax_tests/data/ppx/react/expected/externalWithCustomName.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Foo = {
55
type props<'a, 'b> = {a: 'a, b: 'b}
66

77
@module("Foo")
8-
external component: React.componentLike<props<int, string>, React.element> = "component"
8+
external component: React.component<props<int, string>> = "component"
99
}
1010

1111
let t = React.jsx(Foo.component, {a: 1, b: {"1"}})

tests/syntax_tests/data/ppx/react/expected/externalWithRef.res.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ module V4C = {
88
}
99

1010
@module("componentForwardRef")
11-
external make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element> =
12-
"component"
11+
external make: React.component<props<string, ReactDOM.Ref.currentDomRef>> = "component"
1312
}

tests/syntax_tests/data/ppx/react/expected/externalWithTypeVariables.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ module V4C = {
88
}
99

1010
@module("c")
11-
external make: React.componentLike<props<t<'a>, React.element>, React.element> = "component"
11+
external make: React.component<props<t<'a>, React.element>> = "component"
1212
}

tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ module Select: {
1313
items: 'items,
1414
}
1515

16-
let make: React.componentLike<
16+
let make: React.component<
1717
props<
1818
module(T with type t = 'a and type key = 'key),
1919
option<'key>,
2020
option<'key> => unit,
2121
array<'a>,
2222
>,
23-
React.element,
2423
>
2524
}

tests/syntax_tests/data/ppx/react/expected/forwardRef.resi.txt

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ module V4C: {
99
ref?: 'ref,
1010
}
1111

12-
let make: React.componentLike<
13-
props<string, React.element, ReactDOM.Ref.currentDomRef>,
14-
React.element,
15-
>
12+
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
1613
}
1714

1815
module ForwardRef: {
1916
@res.jsxComponentProps
2017
type props<'ref> = {ref?: 'ref}
2118

22-
let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
19+
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
2320
}
2421
}
2522

@@ -32,17 +29,14 @@ module V4CUncurried: {
3229
ref?: 'ref,
3330
}
3431

35-
let make: React.componentLike<
36-
props<string, React.element, ReactDOM.Ref.currentDomRef>,
37-
React.element,
38-
>
32+
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
3933
}
4034

4135
module ForwardRef: {
4236
@res.jsxComponentProps
4337
type props<'ref> = {ref?: 'ref}
4438

45-
let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
39+
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
4640
}
4741
}
4842

@@ -57,17 +51,14 @@ module V4A: {
5751
ref?: 'ref,
5852
}
5953

60-
let make: React.componentLike<
61-
props<string, React.element, ReactDOM.Ref.currentDomRef>,
62-
React.element,
63-
>
54+
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
6455
}
6556

6657
module ForwardRef: {
6758
@res.jsxComponentProps
6859
type props<'ref> = {ref?: 'ref}
6960

70-
let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
61+
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
7162
}
7263
}
7364

@@ -80,16 +71,13 @@ module V4AUncurried: {
8071
ref?: 'ref,
8172
}
8273

83-
let make: React.componentLike<
84-
props<string, React.element, ReactDOM.Ref.currentDomRef>,
85-
React.element,
86-
>
74+
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
8775
}
8876

8977
module ForwardRef: {
9078
@res.jsxComponentProps
9179
type props<'ref> = {ref?: 'ref}
9280

93-
let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
81+
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
9482
}
9583
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module A: {
22
@res.jsxComponentProps
33
type props<'x> = {x: 'x}
4-
let make: React.componentLike<props<string>, React.element>
4+
let make: React.component<props<string>>
55
}
66

77
module NoProps: {
88
@res.jsxComponentProps
99
type props = {}
1010

11-
let make: React.componentLike<props, React.element>
11+
let make: React.component<props>
1212
}

0 commit comments

Comments
 (0)