Edoardo Luppi
09/21/2023, 11:44 AM@JvmStatic
?andylamax
09/21/2023, 1:49 PMArtem Kobzar
09/22/2023, 7:49 AMEdoardo Luppi
09/22/2023, 8:04 AMpublic class Properties private constructor(private val data: Map<String, String>) {
public companion object {
@JvmStatic
fun decode(string: String): Properties {
...
}
}
}
Will output the following d.ts
:
class Properties {
private constructor();
static get Companion(): {
decode(string: string): Properties;
};
}
I can see two problems from a JS/TS consumer point of view:
1. What's a "companion"?
2. Why can't I simply Properties.decode(...)
To workaround the companion issue I'm now using
@JsName("factory")
public companion object Factory {
So it will look good in all platforms, and a JS/TS consumer can use:
Properties.factory().decode(...)
Artem Kobzar
09/22/2023, 11:26 AMEdoardo Luppi
09/22/2023, 11:34 AM