Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
552 stars 44 forks source link

Static readonly fields generate actual initializer values #415

Closed joffrey-bion closed 2 years ago

joffrey-bion commented 3 years ago

Static readonly fields in TS generate actual initializer values in Kotlin, which is invalid.

Source TS:

export declare class Spinner {
  static readonly SIZE_SMALL = 20;
  static readonly SIZE_STANDARD = 50;
  static readonly SIZE_LARGE = 100;
}

Generated:

external open class Spinner {
    companion object {
        var SIZE_SMALL = 20
        var SIZE_STANDARD = 50
        var SIZE_LARGE = 100
    }
}

Which gives the following compile error:

Wrong initializer of external declaration. Must be ' = definedExternally'

This was noticed in version 0.5.8-rc.0 of Dukat.

JSMonk commented 2 years ago

Fixed in https://github.com/Kotlin/dukat/pull/457, https://github.com/Kotlin/dukat/pull/458