Does each method require @JsName annotation?
I was trying to get NodeJs to work with Kotlin for the HelloWorld example here .
According to the Kotlin JS documentation, the @JsName annotation is required for overloaded methods. But in my experience, this is required even for the single method . Without this annotation, the compiler adds the method name suffix as shown in the screenshot.
This is mistake? Or am I missing something?
I am using the Kotlin 1.1.0 module provided by NPM (please check the GitHub link above for the complete codebase if needed).
source to share
The Kotlin compiler manages the names of all functions except those that take no parameters. The motivation is this: you can add the overloaded function later, and this should not break the binary compatibility of your code. As for @JsName
: it depends on your goal. I don't know this and therefore cannot tell if you have added shoold to annotate @JsName
for each method. If you are developing a library designed to be used with JavaScript, yes, you probably need to place @JsName
for every function you want from JavaScript. We're going to add another annotation that disables manipulation of the entire class or file.
source to share