ankushg
06/04/2020, 3:48 PMtype MyEnum = "a" | "b" | "c"
).
Having inline enum class
support (especially with generates TS definitions) would help greatly with calling Kotlin/JS code from Typescript.
EDIT: it looks like there are a few other ways to represent Enums in TS:
• enum (enum MyEnum2 { A = "a", B = "b", C = "c")
)
• const enum (const enum MyEnum2 { A = "a", B = "b", C = "c")
)
I want proper mapping between Kotlin/TS enums -- inline classes and/or union types are just one way I see to get thatgildor
06/04/2020, 3:52 PMa possibility for inline enum classes to be prioritizedThis is not JS-only feature so it should be discussed in context of all platforms, to prioritize it, we at least need KEEP for it, now it’s just an idea raised during discussion of inline classxes
gildor
06/04/2020, 3:54 PMankushg
06/04/2020, 4:22 PMinline enum class
as the ideal solution.
It looks like Typescript supports:
• string union (type MyEnum1 = "a" | "b" | "c"
)
• enum (enum MyEnum2 { A = "a", B = "b", C = "c")
)
• const enum (const enum MyEnum2 { A = "a", B = "b", C = "c")
)
Do Kotlin `enum class`es get mapped to/from any of these in the new IR's .d.ts generation?Svyatoslav Kuzmich [JB]
06/04/2020, 4:36 PMtype MyEnum4 = { $name: 'A', /* ... */ } | { $name: 'B', /* ... */ }
ankushg
06/04/2020, 4:41 PMSvyatoslav Kuzmich [JB]
06/04/2020, 4:53 PMinline enum class
es are definitely a good fit for JS export. But, I guess, they can be just enum classes with @JsExport
on JS platform only.Sam Garfinkel
06/04/2020, 5:45 PMankushg
06/04/2020, 7:21 PM@JsExport
on a heavyweight Kotlin enum class would be able to cleanly map into a TS enum
, but I'd definitely be in favor of that if possible 🙂