ankushg
01/22/2020, 7:09 PMkotlinx.serialization
almost exclusively to map from Kotlin Enum Classes to `Int`/`String`s for JS, because our deeply nested classes make it difficult to handwrite methods that accept primitives and map them to Kotlin enum classes.
• Is there any way to have Kotlin expose enum class
es as `String`/`Int` values in JS, instead of generated Kotlin classes?
• Will 1.4 be able to expose Kotlin enums as legit Typescript enum constants?
• Is this something that we need `inline enum class`es to solve?turansky
01/22/2020, 10:13 PMInt
<-> Kotlin enum
turansky
01/22/2020, 10:17 PMinterface JsEnum {
val data:Int
}
enum class MyEnum(
override data:Int
)JsEnum {
UP(1),
DOWN(2),
// ...
}
ankushg
01/22/2020, 11:30 PMMyEnum.UP
is still exposed as an object containing { data: 1 }
and not a raw integer literal 1
, right?
I already have custom kotlinx.serialization Serializers defined to go from int/string to enums, but it feels like a nontrivial amount of overhead…turansky
01/23/2020, 11:10 AMInt
-> Enum
-> Int
- responsibility of custom serializer