Description
Currently, default arguments for bindings to external functions can be supplied with
@as(json`someLiteral`) _
where someLiteral
is a JS number, string or object literal.
This is used in several bindings, like in this example (adapted from rescript-react-native):
@val
external unsafeAddStyle: (@as(json`{}`) _, style, {..}) => style = "Object.assign"
Unfortunately, the implementation of this feature in the compiler is quite hacky, requiring special handling for both tagged strings and function arity.
We should therefore try to find a better, but still zero-cost mechanism to replace it.
We discussed that a possible direction to explore would be "zero cost raw functions", meaning that the above example could be written as something like the following, with raw JS code as the function definition:
@rawFunction
external unsafeAddStyle: (style, {..}) => style = "(style, obj) => Object.assign({}, style, obj)"
This means that the raw JS function definition would be inlined where the external is used.
Metadata
Metadata
Assignees
Type
Projects
Status