-
Notifications
You must be signed in to change notification settings - Fork 471
Closed
Description
let f ?x y =
(match x with
| None -> 1
| Some (_:string) -> 2 ) + y
type t = {
y : int [@optional]
}[@@deriving abstract]
let u ?y () = t ?y ()
function f(x, y) {
return (
x !== undefined ? 2 : 1
) + y | 0;
}
function u(y, param) {
var tmp = {};
if (y !== undefined) {
tmp.y = Caml_option.valFromOption(y);
}
return tmp;
}
The second one does not get specialized.
Raised here https://forum.rescript-lang.org/t/how-can-i-get-rid-of-the-runtime-libraries/1001/2
Code snippet:
[@react.component]
let make = (
~href: string,
~className: option(string)=?,
~onClick: option(clickHandler)=?,
~children: React.element,
) => {
let onClick = Belt.Option.getWithDefault(onClick, makeDefaultClickHandler(href));
<a href onClick ?className> children </a>
}
Expanded code:
external makeProps :
href:string ->
?className:string ->
?onClick:clickHandler ->
children:React.element ->
?key:string ->
unit ->
<
href: string ;className: string option ;onClick: clickHandler
option ;
children: React.element > Js.t = ""
Metadata
Metadata
Assignees
Labels
No labels