Hello Everyone! I noticed an odd quirk when you ha...
# javascript
m
Hello Everyone! I noticed an odd quirk when you have a Kotlin/JS module that depends on a multiplatform module: If you have an enum in the multiplatform project and you use
EnumClassHere.values()
in the Kotlin/JS project, it fails with
TypeError: can't access property "values", $module$loritta_<http://api.net|api.net>.perfectdreams.loritta.api.commands.CommandCategory is undefined
As a workaround I added this to my enum class in the multiplatform project
Copy code
init {
   CommandCategory.values().forEach {}
}
...and it worked without any issues! Is this a known issue? (and yes, I did try disabling Kotlin DCE on my JS project, but even with it disabled the error still happened)
👀 1
i
@MrPowerGamerBR Can you attach a link to your project?
m
@Ivan Kubyshkin [JetBrains] This is weird, I was fixing some issues today on my multiplatform branch before I sent the repository to you... and now I can't reproduce the issue, even without the
init
block. But then I hit another similar bug. now when trying to run the JS project it throws
TypeError: can't access property "prototype", LorittaBot is undefined
, compiling the JVM target works fine. Here's the source code: https://github.com/LorittaBot/Loritta/tree/feature/command-dsl You don't need to compile everything, just compile the
:loritta-website:spicy-morenitta
module (it is for the frontend) There is some JS libs that are required to run, so to makes things easier I made a small zip file that contains all dependencies and
index.html
that loads the js files in the right order: https://cdn.discordapp.com/attachments/475830618895155201/676399727729836033/lori_asset_bug.zip
Hmmm I think this is a incremental compiler bug, after rebuilding the API project with
gradle build clean
the issue simply vanished.
Yeah now I can't reproduce the issue after recompiling the API with
clean
. I think that adding the
init
block just caused the compiler to "omg I need to compile this class because it was changed" and that fixed the issue.
i
Failed to reproduce the problem. If you'll reproduce the problem again feel free to tag me.
m
Yeah I'm also not able to reproduce it, and looks like everytime it happens it can be fixed by just doing a
gradle clean
on the multiplatform project, so it is not a huge issue, but thanks for helping 🙂
👍 1