This repository was archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
More generalized props type for ref and type variables #637
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@@jsxConfig({version: 3}) | ||
|
||
module V3 = { | ||
@obj | ||
external makeProps: ( | ||
~x: string, | ||
~ref: ReactDOM.Ref.currentDomRef=?, | ||
~key: string=?, | ||
unit, | ||
) => {"x": string, "ref": option<ReactDOM.Ref.currentDomRef>} = "" | ||
@module("componentForwardRef") | ||
external make: React.componentLike< | ||
{"x": string, "ref": option<ReactDOM.Ref.currentDomRef>}, | ||
React.element, | ||
> = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "classic"}) | ||
|
||
module V4C = { | ||
type props<'x, 'ref> = {x: 'x, ref?: 'ref} | ||
|
||
@module("componentForwardRef") | ||
external make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element> = | ||
"component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "automatic"}) | ||
|
||
module V4C = { | ||
type props<'x, 'ref> = {x: 'x, ref?: 'ref} | ||
|
||
@module("componentForwardRef") | ||
external make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element> = | ||
"component" | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/ppx/react/expected/externalWithTypeVariables.res.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@@jsxConfig({version: 3}) | ||
|
||
module V3 = { | ||
@obj | ||
external makeProps: ( | ||
~x: t<'a>, | ||
~children: React.element, | ||
~key: string=?, | ||
unit, | ||
) => {"x": t<'a>, "children": React.element} = "" | ||
@module("c") | ||
external make: React.componentLike<{"x": t<'a>, "children": React.element}, React.element> = | ||
"component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "classic"}) | ||
|
||
module V4C = { | ||
type props<'x, 'children> = {x: 'x, children: 'children} | ||
|
||
@module("c") | ||
external make: React.componentLike<props<t<'a>, React.element>, React.element> = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "automatic"}) | ||
|
||
module V4C = { | ||
type props<'x, 'children> = {x: 'x, children: 'children} | ||
|
||
@module("c") | ||
external make: React.componentLike<props<t<'a>, React.element>, React.element> = "component" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type props<'x, 'ref> = {x: 'x, ref?: 'ref} | ||
@react.component | ||
let make = ( | ||
{x, _}: props<string, ReactDOM.Ref.currentDomRef>, | ||
ref: Js.Nullable.t<ReactDOM.Ref.currentDomRef>, | ||
) => { | ||
let _ = ref->Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef) | ||
React.string(x) | ||
} | ||
let make = React.forwardRef({ | ||
let \"InterfaceWithRef" = (props: props<_>, ref) => make(props, ref) | ||
\"InterfaceWithRef" | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type props<'x, 'ref> = {x: 'x, ref?: 'ref} | ||
let make: React.componentLike<props<string, ReactDOM.Ref.currentDomRef>, React.element> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@@jsxConfig({version: 3}) | ||
|
||
module V3 = { | ||
@module("componentForwardRef") @react.component | ||
external make: ( | ||
~x: string, | ||
~ref: ReactDOM.Ref.currentDomRef=?, | ||
) => React.element = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "classic"}) | ||
|
||
module V4C = { | ||
@module("componentForwardRef") @react.component | ||
external make: ( | ||
~x: string, | ||
~ref: ReactDOM.Ref.currentDomRef=?, | ||
) => React.element = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "automatic"}) | ||
|
||
module V4C = { | ||
@module("componentForwardRef") @react.component | ||
external make: ( | ||
~x: string, | ||
~ref: ReactDOM.Ref.currentDomRef=?, | ||
) => React.element = "component" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@@jsxConfig({version: 3}) | ||
|
||
module V3 = { | ||
@module("c") @react.component | ||
external make: ( | ||
~x: t<'a>, | ||
~children: React.element, | ||
) => React.element = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "classic"}) | ||
|
||
module V4C = { | ||
@module("c") @react.component | ||
external make: ( | ||
~x: t<'a>, | ||
~children: React.element, | ||
) => React.element = "component" | ||
} | ||
|
||
@@jsxConfig({version: 4, mode: "automatic"}) | ||
|
||
module V4C = { | ||
@module("c") @react.component | ||
external make: ( | ||
~x: t<'a>, | ||
~children: React.element, | ||
) => React.element = "component" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@react.component | ||
let make = React.forwardRef((~x: string, ref: Js.Nullable.t<ReactDOM.Ref.currentDomRef>) => { | ||
let _ = ref->Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef) | ||
React.string(x) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@react.component | ||
let make: (~x: string, ~ref: ReactDOM.Ref.currentDomRef=?) => React.element |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.