Kotlin / dukat

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

Literal type could be represented with inline vals #395

Open KotlinIsland opened 3 years ago

KotlinIsland commented 3 years ago
declare function foo(name: "foo" | "bar"): void

Could be represented with:

external fun foo(name: NameOption)

@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
external interface NameOption {
    companion object
}
inline val NameOption.Companion.foo get() = "foo".asDynamic().unsafeCast<NameOption>()
inline val NameOption.Companion.bar get() = "bar".asDynamic().unsafeCast<NameOption>()