Replies: 3 comments
|
Could you please share the JavaScript/TypeScript code which is trying to be mapped by this code? |
0 replies
|
https://unpkg.com/browse/react-router@7.0.2/dist/development/index.d.ts interface NavigateFunction {
(to: To, options?: NavigateOptions): void | Promise<void>;
(delta: number): void | Promise<void>;
}
declare function useNavigate(): NavigateFunction;Also, just found this convenient interface for looking up the types for a lib https://types.kubajastrz.com/ |
0 replies
|
The other alternative is to not use This is what Glutinum generates right now: [<AbstractClass>]
[<Erase>]
type Exports =
[<Import("useNavigate", "REPLACE_ME_WITH_MODULE_NAME")>]
static member useNavigate () : NavigateFunction = nativeOnly
[<AllowNullLiteral>]
[<Interface>]
type NavigateFunction =
[<Emit("$0($1...)")>]
abstract member Invoke: ``to``: To * ?options: NavigateOptions -> U2<unit, JS.Promise<unit>>
[<Emit("$0($1...)")>]
abstract member Invoke: delta: float -> U2<unit, JS.Promise<unit>>In a ideal world useNavigate.Invoke("to-somewhere", NavigateOptions(
replace = true
)
)when in TypeScript you would write useNavigate("to-somewhere", {
replace: true
})You could perhaps optimise it even more by generating something like that [<AbstractClass>]
[<Erase>]
type Exports =
[<Emit("$0($1...)")>]
[<Import("useNavigate", "REPLACE_ME_WITH_MODULE_NAME")>]
abstract member Invoke: ``to``: To * ?options: NavigateOptions -> U2<unit, JS.Promise<unit>>
[<Emit("$0($1...)")>]
[<Import("useNavigate", "REPLACE_ME_WITH_MODULE_NAME")>]
abstract member Invoke: delta: float -> U2<unit, JS.Promise<unit>> |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When writing bindings for something like a hook that returns a function, where the returned function takes a params object, it would be convenient to be able to define a delegate that uses
ParamObject:The alternative is using a type with
Emit("$0($1...)")(Maybe the second one could also be made prettier and less error prone to type with an
EmitApplyorEmitCallhelper?)All reactions