andylamax
12/28/2020, 6:48 AM@JsExports
should work in the near future
Let @JsExport
export every thing to global namespace. Example in a module sea
file: sea/src/main/kotlin/com/sea/entities.kt
package com.sea
@JsExport
class Fish(val type: String = "Tilapia")
@JsExport
class Whale(val name: String = "Deep Blue")
and to be use in typescript as
import { Whale, Fish } from 'sea'
const whale = new Whale("Killer Whale");
const tilapia = new Fish();
However, since sometimes scoping is needed. We can pass parameters to the @JsExport
like so
package com.sea
@JsExport
class Fish(val type: String = "Tilapia")
@JsExport("mammals")
class Whale(val name: String = "Deep Blue")
and to be use in typescript as
import { mammals, Fish } from 'sea'
const whale = new mammals.Whale("Killer Whale");
const tilapia = new Fish();
I know this is hard right now (due to how the Compiler build js), but the very desired sytax from the above case is
import { Fish } from 'sea'
import { Whale } from 'sea/mammals'
const whale = new Whale("Killer Whale");
const tilapia = new Fish();
I hope this one gets some love
Issue is already on YT at https://youtrack.jetbrains.com/issue/KT-37710 please give more votesturansky
12/28/2020, 12:49 PM