Hi, I am trying to import module in kotlinJs ```@J...
# javascript
t
Hi, I am trying to import module in kotlinJs
Copy code
@JsModule("botui")
external class BotUI(name: String) {}
Copy code
val bot = BotUI("test")
and I am getting error
$module.$botui is not a constructor
botui module exports only one class as a default. Should I use different approach when module has only default export?
t
Try this:
Copy code
@file:JsModule("botui")

@JsName("default")
external class BotUI(name: String) {}
t
Thank you. I looks like a way to go, but I run into another issue:
Unexpected token in...
Copy code
if (typeof default === 'undefined') {
It seems that "default" needs to be somehow escaped.
Ok, I found it @JsName behaves differently when it's combined
@file:JsModule()
and
JsModule("")
t
Works?
t
Yes, thank you. It only works when it is defined in own file using @file:JsModule.
👍 1
t
Feel free to vote for more transparent import.