https://kotlinlang.org logo
#javascript
Title
# javascript
j

janvladimirmostert

06/21/2022, 7:58 PM
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

janvladimirmostert

06/21/2022, 8:54 PM
that works for the KotlinJS side, is there something that will work for common, jvm and js (especially for @JsExport)?
b

Big Chungus

06/21/2022, 9:02 PM
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

janvladimirmostert

06/21/2022, 9:07 PM
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

Grégory Lureau

06/22/2022, 7:21 AM
Is it open-source? I'd try to implement support for Map in KustomExport but I don't have a real usage right now 🙂
11 Views