Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#### :house: Internal

- JSX PPX: use `React.component` instead of `React.componentLike` for externals. https://github.com/rescript-lang/rescript/pull/7952

# 12.0.0-rc.1

#### :nail_care: Polish
Expand Down
8 changes: 4 additions & 4 deletions compiler/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@ let transform_structure_item ~config item =
(* can't be an arrow because it will defensively uncurry *)
let new_external_type =
Ptyp_constr
( {loc = pstr_loc; txt = module_access_name config "componentLike"},
[ret_props_type; jsx_element_type config ~loc:pstr_loc] )
( {loc = pstr_loc; txt = module_access_name config "component"},
[ret_props_type] )
in
let new_structure =
{
Expand Down Expand Up @@ -1079,8 +1079,8 @@ let transform_signature_item ~config item =
(* can't be an arrow because it will defensively uncurry *)
let new_external_type =
Ptyp_constr
( {loc = psig_loc; txt = module_access_name config "componentLike"},
[ret_props_type; jsx_element_type config ~loc:psig_loc] )
( {loc = psig_loc; txt = module_access_name config "component"},
[ret_props_type] )
in
let new_structure =
{
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/src/expected/Jsx2.resi.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hover src/Jsx2.resi 1:4
{"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"}}
{"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"}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any comments on this change @cknitt ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why this happens, but now it's back to where it was before #7939, see also the comment there: #7939 (comment)


Hover src/Jsx2.resi 4:4
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module C6 = {
@res.jsxComponentProps
type props = {}

let make: React.componentLike<props, React.element>
let make: React.component<props>
}
@res.jsxComponentProps
type props<'comp, 'x> = {comp: 'comp, x: 'x}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Foo = {
type props<'a, 'b> = {a: 'a, b: 'b}

@module("Foo")
external component: React.componentLike<props<int, string>, React.element> = "component"
external component: React.component<props<int, string>> = "component"
}

let t = React.jsx(Foo.component, {a: 1, b: {"1"}})
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ module V4C = {
}

@module("componentForwardRef")
external make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element> =
"component"
external make: React.component<props<string, ReactDOM.Ref.currentDomRef>> = "component"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module V4C = {
}

@module("c")
external make: React.componentLike<props<t<'a>, React.element>, React.element> = "component"
external make: React.component<props<t<'a>, React.element>> = "component"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ module Select: {
items: 'items,
}

let make: React.componentLike<
let make: React.component<
props<
module(T with type t = 'a and type key = 'key),
option<'key>,
option<'key> => unit,
array<'a>,
>,
React.element,
>
}
28 changes: 8 additions & 20 deletions tests/syntax_tests/data/ppx/react/expected/forwardRef.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ module V4C: {
ref?: 'ref,
}

let make: React.componentLike<
props<string, React.element, ReactDOM.Ref.currentDomRef>,
React.element,
>
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
}

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

let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
}
}

Expand All @@ -32,17 +29,14 @@ module V4CUncurried: {
ref?: 'ref,
}

let make: React.componentLike<
props<string, React.element, ReactDOM.Ref.currentDomRef>,
React.element,
>
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
}

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

let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
}
}

Expand All @@ -57,17 +51,14 @@ module V4A: {
ref?: 'ref,
}

let make: React.componentLike<
props<string, React.element, ReactDOM.Ref.currentDomRef>,
React.element,
>
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
}

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

let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
}
}

Expand All @@ -80,16 +71,13 @@ module V4AUncurried: {
ref?: 'ref,
}

let make: React.componentLike<
props<string, React.element, ReactDOM.Ref.currentDomRef>,
React.element,
>
let make: React.component<props<string, React.element, ReactDOM.Ref.currentDomRef>>
}

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

let make: React.componentLike<props<React.ref<Js.Nullable.t<inputRef>>>, React.element>
let make: React.component<props<React.ref<Js.Nullable.t<inputRef>>>>
}
}
4 changes: 2 additions & 2 deletions tests/syntax_tests/data/ppx/react/expected/interface.resi.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module A: {
@res.jsxComponentProps
type props<'x> = {x: 'x}
let make: React.componentLike<props<string>, React.element>
let make: React.component<props<string>>
}

module NoProps: {
@res.jsxComponentProps
type props = {}

let make: React.componentLike<props, React.element>
let make: React.component<props>
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@res.jsxComponentProps type props<'x, 'ref> = {x: 'x, ref?: 'ref}
let make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element>
let make: React.component<props<string, ReactDOM.Ref.currentDomRef>>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module C4A1 = {
@res.jsxComponentProps @live
type props<'T_open, 'T_type> = {@as("open") _open: 'T_open, @as("type") _type: 'T_type}

external make: React.componentLike<props<string, string>, React.element> = "default"
external make: React.component<props<string, string>> = "default"
}

let c4a0 = React.jsx(C4A0.make, {_open: "x", _type: "t"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module V4CB = {
type props = {}

@module("c")
external make: React.componentLike<props, React.element> = "component"
external make: React.component<props> = "component"
}

module V4C = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ module V4A4 = {
module V4A5 = {
type props = sharedProps<string>

external make: React.componentLike<props, React.element> = "default"
external make: React.component<props> = "default"
}

module V4A6 = {
type props<'a> = sharedProps<'a>

external make: React.componentLike<props<_>, React.element> = "default"
external make: React.component<props<_>> = "default"
}

module V4A7 = {
type props<'a> = sharedProps<string, 'a>

external make: React.componentLike<props<_>, React.element> = "default"
external make: React.component<props<_>> = "default"
}

module V4A8 = {
type props = sharedProps

external make: React.componentLike<props, React.element> = "default"
external make: React.component<props> = "default"
}
16 changes: 8 additions & 8 deletions tests/syntax_tests/data/ppx/react/expected/sharedProps.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@
module V4C1: {
type props = sharedProps<string>

let make: React.componentLike<props, React.element>
let make: React.component<props>
}

module V4C2: {
type props<'a> = sharedProps<'a>

let make: React.componentLike<props<_>, React.element>
let make: React.component<props<_>>
}

module V4C3: {
type props<'a> = sharedProps<string, 'a>

let make: React.componentLike<props<_>, React.element>
let make: React.component<props<_>>
}

module V4C4: {
type props = sharedProps

let make: React.componentLike<props, React.element>
let make: React.component<props>
}

@@jsxConfig({version: 4, mode: "automatic"})

module V4A1: {
type props = sharedProps<string>

let make: React.componentLike<props, React.element>
let make: React.component<props>
}

module V4A2: {
type props<'a> = sharedProps<'a>

let make: React.componentLike<props<_>, React.element>
let make: React.component<props<_>>
}

module V4A3: {
type props<'a> = sharedProps<string, 'a>

let make: React.componentLike<props<_>, React.element>
let make: React.component<props<_>>
}

module V4A4: {
type props = sharedProps

let make: React.componentLike<props, React.element>
let make: React.component<props>
}
6 changes: 3 additions & 3 deletions tests/syntax_tests/data/ppx/react/expected/v4.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ module type TUncurried = {
@res.jsxComponentProps
type props<'x> = {x: 'x}

let make: React.componentLike<props<string>, React.element>
let make: React.component<props<string>>
}

module E = {
@res.jsxComponentProps @live
type props<'x> = {x: 'x}

external make: React.componentLike<props<string>, React.element> = "default"
external make: React.component<props<string>> = "default"
}

module EUncurried = {
@res.jsxComponentProps @live
type props<'x> = {x: 'x}

external make: React.componentLike<props<string>, React.element> = "default"
external make: React.component<props<string>> = "default"
}

module Rec = {
Expand Down
Loading