No solution for the kotlin test in JS and ```Name ...
# javascript
e
No solution for the kotlin test in JS and
Copy code
Name contains illegal chars that can't appear in JavaScript identifier
?
i
Not that I know of, I wish it just added underscores for you 😞
e
Oke, removing js from supported targets for now
i
you might be able to use
@JsName
to work around it? I haven't tried that though.
e
It would be a solution but have 50+ tests
Sure I can try find and replace with regex but not today
i
Right, not a great solution. Maybe there is another solution?
e
Hence my question - hope someone knows it
Big hope!
🤝 1
e
What's the name?
e
e
Oh I meant the name that you're trying to use and that gives you the error.
e
Ah 🙂
Copy code
fun `Test something is happening here` () {}
Whitespaces are problem
e
Ah yup, for functions unfortunately there is no solution that I know of. I was thinking about properties, as that's been fixed a while ago.
e
Thanks!
a
Actually, since 2.1 such naming is allowed
If you have a version less than 2.1, you can turn it on with the following compiler flag:
Copy code
"-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping"
e
I'm definitely on the latest stable (2.1.20) kotlin
a
Is it possible that you set up a lower than 2.1 language version somewhere in the settings?
thank you color 2
e
Not sure I understood the question
Opened playground and modified function name to have whitespace in
Looks like working
I will try to find what is going wrong with my project
e
You might have stuff like:
Copy code
compilerOptions {
  apiVersion.set(KotlinVersion.KOTLIN_1_9)
  languageVersion.set(KotlinVersion.KOTLIN_1_9)
}
in your build config. I forget about that frequently.
thank you color 1
e
Ah true!
I'm writing a library, so decided to be on the safe side for clients
Thanks!!
i
What happens with that flag on? All I can find is a statement that it fixes the issue but what does it actually do?
e
All I can find is a statement that it fixes the issue but what does it actually do?
It transforms the code into something like:
Copy code
instance['method name with spaces'] = function ...
👍 1
a
@Edoardo Luppi, not for all members. It does this transformation for the exported members only, for non-exported members it just transform it into
method_name_with_spaces
(and eliminating clashes with the same named member): https://pl.kotl.in/3pXKkyGRS
e
Yup noticed it in the playground earlier and I figured the explanation for exported declarations was better, but indeed thanks for the clarification!
If I recall correctly, the original issue was made for compatibility with externals. I had a similar issue when trying to code externals for VS Code.
a
I don't remember, to be honest. There were a few of them (for externals and for tests) and I don't remember which one was the first 😅
e
Np, thanks again for clarifying that difference between exported and non-exported