What is the correct type to use in Kotlin in order...
# javascript
j
What is the correct type to use in Kotlin in order to get an exported type as {} in JavaScript? I've tried Map, but IJ is complaining "Exported declaration uses non-exportable parameter type: Map<String, String>" Instead of List, I have to use Array to get [] in JavaScript / TypeScript, what type will give me a JavaScript object, {}
j
that works for the KotlinJS side, is there something that will work for common, jvm and js (especially for @JsExport)?
b
Why not record? external interface Record<T>
Then expect actuals it into common
Otherwise, no there's no such thing in first party libs
j
it's starting to sound easier just to have separate APIs for JS and JVM side, then I can use Map for the JVM and JSON for JS side. already had to do JS
Copy code
fun get(url: String): Promise<HTTP>
JVM
Copy code
suspend fun get(url: String): Result<HTTP>
since suspend functions doesn't export thanks for the feedback!
not as pretty as I would have liked, but it'll work
g
Is it open-source? I'd try to implement support for Map in KustomExport but I don't have a real usage right now 🙂