Marc
04/01/2026, 2:57 PM@JsStatic cannot be applied to members of of non-companion obvious, when this pattern works just fine with @JvmStatic? To be fair this limitation is mentioned in the associated KDoc comment, but it would be nice if the behaviour was consistent with @JvmStatic.Edoardo Luppi
04/01/2026, 3:02 PMobject Example {
fun myFun() {}
}turansky
04/01/2026, 3:05 PMMarc
04/01/2026, 3:07 PMEdoardo Luppi
04/01/2026, 3:19 PM@JsStatic on object members should work just fine, as it does with companion ones.Edoardo Luppi
04/01/2026, 3:20 PMMarc
04/01/2026, 3:20 PMOnly members of class companion objects can be annotated with '@JsStatic'. for me.Edoardo Luppi
04/01/2026, 3:21 PMEdoardo Luppi
04/01/2026, 3:23 PM@JsStatic could compile to (taking my previous example):
function myFun() {
return getExampleInstance().myFun();
}
class Example {
myFun() {
return "two"
}
}
var example;
function getExampleInstance() {
if (!example) {
example = new Example();
}
return example;
}
Example.myFun = myFun;
console.log(Example.myFun())
console.log(new Example().myFun())Artem Kobzar
04/01/2026, 3:28 PMMarc
04/01/2026, 3:37 PMMarc
04/01/2026, 3:46 PMxxxStatic annotations behave consistently.Artem Kobzar
04/01/2026, 5:12 PMEdoardo Luppi
04/01/2026, 5:12 PMgetInstance() call.Artem Kobzar
04/01/2026, 5:13 PMcompanion block feature pepenotingfastMarc
04/02/2026, 7:25 AMnamespace is introduced). Then I think it makes sense to fix the current interaction with objects.