Hi. Is there any way to explicitly define the Type...
# javascript
f
Hi. Is there any way to explicitly define the TypeScript signature of an exported type? I want to expose tuples (e.g. Kotlin's
Pair
) as Javascript arrays. However I would like the TypeScript signature to reflect the original tuple types. E.g. Expose
Pair<Int, String>
as an
Array
, however have the TypeScript type be
[number, string]
t
Direct analog of TS tuple for 2 -
JsTuple2
. To construct it you can use
tupleOf
factory function.
f
Thanks. However I'm getting the following warning
Copy code
Exported declaration uses non-exportable return type: JsTuple2<Any, Any>
I assumed that
JsTuple2<T,U>
is exportable if
T
and
U
are exportable. Am I wrong in assuming this?
Here is the generated TypeScript
Copy code
export declare function removed(...): any/* js.core.JsTuple2<any, any> */;
t
Root cause - now
JsTuple2
is non-external It will be possible to fix modifier in Kotlin
1.9
only (compiler fixes required)
f
Am I correct in thinking that it should be exportable, or am I missing something?
t
As I know
external
-> exportable
But it looks like postprocessing will be required
You will need additional aliases in file, like:
type JsTuple2<A, B> = [A, B]