0

I'm using kotlin2js to generate JS library from Kotlin code. I'm then using this library in Javascript (not Kotlin). The code has some Kotlin objects and some normal classes. I can access normal classes from Javascript, but I can't access the objects in any way.

The documentation is pretty sparse, only relevant line might be this:

Kotlin preserves lazy object initialization in JavaScript.

I'm not sure what that means.

David Vávra
  • 18,446
  • 7
  • 48
  • 56

2 Answers2

0

I suppose you should specify moduleName as well when accessing from javascript.

Roman Art
  • 126
  • 2
0

The problem was that Kotlin changed name of the method to something like this: calculate_ywek2$(). And it's very hard to figure out, because Kotlin doesn't generate Typescript definitions, so autocomplete doesn't work. The name can be changed with @JsName annotation.

David Vávra
  • 18,446
  • 7
  • 48
  • 56