I am using the kotlin react wrappers and everythin...
# javascript
a
I am using the kotlin react wrappers and everything is going great, however I want to create a library, with TS definitions, that defines some hooks. These hooks should return an array with two parameters, say S and T. But, how do I define the types such that I get a proper TS signature? What I mean is that I need the function to return
[S, T]
and that my TS consumer code can use array desctructuring. However, I see no way to cleverly do this in Kotlin.
a
Have you tried using a
Pair
?
t
You need
JsTuple2<S, T>
. To create it you can use
tupleOf
factory. cc @Sergei Grishchenko
🎉 1
a
Hmm, the typescript definitions are not correct.
Copy code
export declare namespace todo {
    function useTodoViewModel(): JsTuple2<todo.TodoState, TodoMutableViewModel>;
}
I'd expect:
Copy code
export declare namespace todo {
    function useTodoViewModel(): [todo.TodoState, TodoMutableViewModel];
}
It also throws an error for JsTuple2. I don't think it is supported
@Andromadus Naruto Pair isn't exportable using JsExport
t
For now you can add
JsTuple2
declaration in additional
.d.ts
file
a
Yes that makes sense