ts-generator icon indicating copy to clipboard operation
ts-generator copied to clipboard

Sharing constants

Open Vlad8161 opened this issue 5 years ago • 1 comments

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"
}

Vlad8161 avatar Sep 29 '20 16:09 Vlad8161

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

brezinajn avatar Sep 29 '20 21:09 brezinajn