is there a way to turn Kotlin enums into JS string...
# javascript
b
is there a way to turn Kotlin enums into JS string enums for interop? basically emulate TypeScript's string enums like:
Copy code
type Role = "Admin" | "User"
1
e
If you mean exporting a TS
type
with
generateTypeScriptDefinitions()
, than nope unfortunately.
But it's a fair choice, Kotlin's enums are complex objects compared to other languages' enums, so there is no direct translation without losing functionalities.
b
I see, yeah, I just want to create better external type definitions for a JS API
e
Using enums is still straightforward from a TS consumer POV tho
e
I don't know if this is exactly what you meant but there has been discussions around having inline enum classes that might have the functionality you describe https://youtrack.jetbrains.com/issue/KT-23823/Support-inline-enum-classes
👀 1
b
yeah, that's sorta what I want, but I want to define that for an external function
you'd probably need to define that parameter as an inline enum in that case