We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unit
The following code:
external useFoo : unit -> string -> string = "useFoo" let foo = useFoo () let t = foo ""
generates this output:
function foo(param) { return useFoo(param); } var t = useFoo("");
Playground.
Note how t is converted into useFoo("") and not useFoo(undefined, ""). When using any other type, the first parameter will be passed just fine:
t
useFoo("")
useFoo(undefined, "")
external useFoo : int -> string -> string = "useFoo" let foo = useFoo 2 let t = foo ""
Output:
function foo(param) { return useFoo(2, param); } var t = useFoo(2, "");
Playground
Is this expected?
The text was updated successfully, but these errors were encountered:
I'm looking into this, but one workaround is:
type t = unit external useFoo : t -> string -> string = "useFoo"
Sorry, something went wrong.
I still need to do more digging, but the issue here seems to be that unit is ignored for cases like:
type t external foo: unit -> t = ""
and generating foo() instead of foo(undefined)
foo()
foo(undefined)
One idea is to only elide the unit argument when it appears before the return value, but a "return value" could be a function, too.
This might work well with uncurried.
No branches or pull requests
The following code:
generates this output:
Playground.
Note how
t
is converted intouseFoo("")
and notuseFoo(undefined, "")
. When using any other type, the first parameter will be passed just fine:Output:
Playground
Is this expected?
The text was updated successfully, but these errors were encountered: