The @JsName annotation works great for specifying the js-name but it doesn’t work (1.1.2) for shared code. Is there a way for specifying the annotation on shared code? I guess the annotation should be moved to kotlin-stdlib-common?
We’re considering exposing these annotations (JsName
, JvmName
etc) in kotlin-stdlib-common.
Could you describe your use case, why would you like to apply this annotation to shared code?
I have some classes in my shared project (compiled to js and to bytecode).
E.g.
interface PresentationModel {
val id: ModelId
val type: ModelType
fun getProperties(): Array<Property>
//@JsName("getByName")
operator fun get(propertyName: PropertyName): Property
}
For the get method the KotlinJs compiler generates get_lqljjj$
as a method name. Which is very unpractical. Of course in the index.d.ts file you can specify this method name, so you have code-completion, none the less, a getByName would be much nicer.