Is it possible to use `@JsName` on properties decl...
# javascript
m
Is it possible to use
@JsName
on properties declared on a
@JsPlainObject
? I wanted to change some
snake_case
variables into
camelCase
, to make it look "better" in Kotlin I tried searching for it, but the only result of someone trying to do this was this conversation: https://kotlinlang.slack.com/archives/C0B8L3U69/p1728428182216839 However after testing it, it doesn't seem to work on Kotlin 2.2.0 😞
t
It looks like bug, JsName should be respected
Could you please report an issue?
m
Sure! I will just make sure that I can reproduce the bug on Kotlin 2.2.20 first
But "technically" the bug has already been reported before by Chris https://youtrack.jetbrains.com/issue/KT-72474/JsPlainObject-doesnt-honour-XXLanguageJsAllowInvalidCharsIdentifiersEscaping While the issue title talks about
-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping
, it seems that the real issue is just that
@JsPlainObject
does not respect
@JsName
However the issue was closed due to inactivity because it seems a repro project was never submitted @turansky
👀 1
Here's a repository with the reproduction steps kodee loving: https://github.com/MrPowerGamerBR/JsPlainObjectJsNameBug I've decided to reply to the KT-72474 issue instead of creating a new issue because, technically, the KT-72474 issue is the same issue that I'm having, with the caveat that the original author thought that this issue only happened when using
-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping
when, in reality, it happens no matter if you use it or not. However if creating a new issue would be a better idea, please let me know. :)
t
Issue reopened! 😉
m
So, I've decided to debug a bit deep to try to figure out what it is, and I think the issue is that the JsName annotation is never checked here: https://github.com/JetBrains/kotlin/blob/f7172786efae0b76fb30c22e718f77b26bea7d17/[…]rains/kotlinx/jso/compiler/backend/JsObjectLoweringExtension.kt However, when experimenting, it seems that I can't access any of the property annotations in the loop (all
IrValueParameter
have a empty list for the annotations field) And because I have never created a K2 plugin before, I'm way out of my depth for this, but I hope that this can be fixed soon :)
t
Yes, information about JS name should be copied somehow to function parameter 😉
m