When testing Kotlin 2.2.20 (currently RC-266) I've...
# webassembly
r
When testing Kotlin 2.2.20 (currently RC-266) I've noticed external classes declared in my code no longer work if there are no real classes in JS. More in thread 🧵
👀 1
Until 2.2.0 I was using a declarations like this: https://github.com/rjaros/kilua/blob/kotlin-2.2.20/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Locales.kt#L33-L36 to simplify my code (I declared a bunch of external objects below the class definition without any additional properties declarations). This was working correctly with 2.2.0 and is still working correctly for the JS target with 2.2.20.
But with wasmJs target on 2.2.20 I've got a runtime error:
Copy code
TempusDominusLocale is not defined
dev.kilua.externals.TempusDominusLocale_$external_class_instanceof@webpack-internal:///./kotlin/kilua-project-examples-playground.uninstantiated.mjs:13228:100
<dev.kilua:playground>.dev.kilua.externals.TempusDominusLocale_$external_class_instanceof__externalAdapter@http://localhost:3000/34442f042fcc762b1ae2.wasm:wasm-function[58947]:0x6b8e62
<dev.kilua:playground>.dev.kilua.form.time.AbstractRichDateTime.initializeTempusDominus@http://localhost:3000/34442f042fcc762b1ae2.wasm:wasm-function[59599]:0x6c6c27
The message is correct, there is no
TempusDominusLocale
class in JS.
But I can't find an issue in the changelog.
And yes, I can change
class
to
interface
and declare overrides for the properties in all my external objects to fix the problem (it's just a bit more code).
Shouldn't JS interop work the same with JS and wasmJS targets?
t
Looks like expected error 🙂
Probably issue, which you search, was reported by Robert Jaros - KT-76509 🙂
and declare overrides for the properties in all my external objects
You can declare "mixin" to avoid redundant overrides
thank you color 1
r
Love adding more magic suppressions to my code 😜
t
Mixin issue will be helpful 😉
r
@JsExternalInheritorsOnly
what does this do?
t
Limit inheritance
It won't be possible to declare non-external inheritor
r
It's used by some compiler plugin?
t
It's part of Kotlin/JS
It will check it
r
And is it required for mixin? Or just added for some other reasons.
t
In case of real mixins your nearest child should be external
r
Works perfect. Thanks once again!
t
In wrappers we mark ~50% of mixins as "external only"
Other part we will mark later as "no direct inheritors outside the project"
With help of this annotation
100+ mixins in browser 😉 Looks like issue