-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: option type in external generation (#791)
* fix: option type in external generation * test: add test for signature + option type * fix structure vs signature issue * address review
- Loading branch information
1 parent
1fdc7b1
commit 76d5ea8
Showing
5 changed files
with
182 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,42 @@ | ||
module Greeting: { | ||
[@react.component] | ||
let make: (~mockup: string=?) => React.element; | ||
} = { | ||
[@react.component] | ||
let make = (~mockup: option(string)=?) => { | ||
<button> {React.string("Hello!")} </button>; | ||
}; | ||
}; | ||
|
||
module MyPropIsOptionBool = { | ||
[@react.component] external make: (~myProp: bool=?) => React.element = "A"; | ||
}; | ||
|
||
module MyPropIsOptionOptionBool = { | ||
[@react.component] | ||
external make: (~myProp: option(bool)=?) => React.element = "B"; | ||
}; | ||
|
||
module MyPropIsOptionOptionBoolWithSig: { | ||
[@react.component] | ||
external make: (~myProp: option(bool)=?) => React.element = "B"; | ||
} = { | ||
[@react.component] | ||
external make: (~myProp: option(bool)=?) => React.element = "B"; | ||
}; | ||
|
||
module MyPropIsOptionOptionBoolWithValSig: { | ||
[@react.component] | ||
let make: (~myProp: option(bool)=?) => React.element; | ||
} = { | ||
[@react.component] | ||
external make: (~myProp: option(bool)=?) => React.element = "B"; | ||
}; | ||
|
||
module MyPropIsOptionOptionBoolLetWithValSig: { | ||
[@react.component] | ||
let make: (~myProp: option(bool)=?) => React.element; | ||
} = { | ||
[@react.component] | ||
let make = (~myProp: option(option(bool))=?) => React.null; | ||
}; |
This file contains 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,106 @@ | ||
$ ../ppx.sh --output ml input.re | ||
module Greeting : | ||
sig | ||
external makeProps : | ||
?mockup:string -> | ||
?key:string -> unit -> < mockup: string option > Js.t = "" | ||
[@@mel.obj ] | ||
val make : | ||
(< mockup: string option > Js.t, React.element) React.componentLike | ||
end = | ||
struct | ||
external makeProps : | ||
?mockup:string -> | ||
?key:string -> unit -> < mockup: string option > Js.t = "" | ||
[@@mel.obj ] | ||
let make = | ||
((fun ?mockup:(mockup : string option) -> | ||
React.DOM.jsx "button" | ||
(((React.DOM.domProps)[@merlin.hide ]) | ||
~children:(React.string "Hello!") ())) | ||
[@warning "-16"]) | ||
let make = | ||
let Output$Greeting (Props : < mockup: string option > Js.t) = | ||
make ?mockup:(Props ## mockup) in | ||
Output$Greeting | ||
end | ||
module MyPropIsOptionBool = | ||
struct | ||
external makeProps : | ||
?myProp:bool -> ?key:string -> unit -> < myProp: bool option > Js.t | ||
= ""[@@mel.obj ] | ||
external make : | ||
(< myProp: bool option > Js.t, React.element) React.componentLike = | ||
"A" | ||
end | ||
module MyPropIsOptionOptionBool = | ||
struct | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
external make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike = "B" | ||
end | ||
module MyPropIsOptionOptionBoolWithSig : | ||
sig | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
external make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike = "B" | ||
end = | ||
struct | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
external make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike = "B" | ||
end | ||
module MyPropIsOptionOptionBoolWithValSig : | ||
sig | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
val make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike | ||
end = | ||
struct | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
external make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike = "B" | ||
end | ||
module MyPropIsOptionOptionBoolLetWithValSig : | ||
sig | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
val make : | ||
(< myProp: bool option option > Js.t, React.element) | ||
React.componentLike | ||
end = | ||
struct | ||
external makeProps : | ||
?myProp:bool option -> | ||
?key:string -> unit -> < myProp: bool option option > Js.t = "" | ||
[@@mel.obj ] | ||
let make = ((fun ?myProp:(myProp : bool option option) -> React.null) | ||
[@warning "-16"]) | ||
let make = | ||
let Output$MyPropIsOptionOptionBoolLetWithValSig | ||
(Props : < myProp: bool option option > Js.t) = | ||
make ?myProp:(Props ## myProp) in | ||
Output$MyPropIsOptionOptionBoolLetWithValSig | ||
end |
This file contains 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