ts-generator
ts-generator copied to clipboard
Sharing constants
Hello. Is there any way to share constants between kotlin and typescript?
For example:
object ApiConstants {
const val SOME_VAL_1 = 1234
const val SOME_VAL_2 = "hello world"
}
Expected TS output:
let ApiConstants = {
SOME_VAL_1: 1234,
SOME_VAL_2: "hello world"
}
Disclaimer: I'm not in any way affiliated with development of this library. I've had the same problem. Solved it with a bit of post processing with enum types (can really share only strings). Anyway this should be totally possible with kotlin compiler only. Check this https://kotlinlang.org/docs/reference/js-ir-compiler.html