ankushg
02/19/2022, 6:09 PM@JsExport
? Like a @JsHide
?
If I have a class in a KMP project that has a public suspend fun
that’s intentionally public for non-JS platforms. That class also has several other valid-for-export methods (including a callback-based API for said suspend fun
), but because of that single coroutine, I can’t currently mark the class as @JsExport
I’d love to be able to tell the compiler to export everything except that pesky suspend fun
Is my only option right now to suppress the warning? It looks like the compiler just drops a comment into the generated .d.ts
file, but it would be nice to tell it that I don’t want to export that method at allMatthias Geisler
02/19/2022, 8:11 PMMatthias Geisler
02/19/2022, 8:30 PMandylamax
02/20/2022, 12:57 AM@JvmSynthetic
You can author a class and mark certain methods to not be available for the Jvm.
If the team saw an importance of it in the Jvm, It is also important in the Js World. Something like a @JsSynthetic
would definitely suffice.
And just to be feature complete, and introduction of @NativeSythentic
for hiding native exports, would be a grate fitMatthias Geisler
02/20/2022, 1:38 AM@JvmSynthetic
has a direct correspondent in Java, Js or Native don't have such things. In certain cases visibility modifiers might suffice (or even remove them entirely), but in terms of suspending functions it won't, since you have no equivalent and a transformation in something which is compatible with the target platform is not trivial. Otherwise projects like NativeCoroutines would not exist, I believe.andylamax
02/20/2022, 1:44 AM@JvmSynthetic
available for Jvm and there is no Js and Native equivalent?? Coz @JvmSynthetic
works so well for suspending functions (and other usecases) in the Jvm, it should also work for Js and Native.Matthias Geisler
02/20/2022, 2:03 AMandylamax
02/20/2022, 2:36 AM@JvmSythentic
.
If I were to be on the kotlin compiler team, this annotation would ask the compiler to turn off the warning of the exported file to js, mangle it up like a non exported member and more over, inhibit the typescript definition of the said file.
As an active user of kotlin/js. This would be extremely sufficient for us. I can't say much about native as my experience is lacking in that departmentMatthias Geisler
02/20/2022, 3:38 AM