Kotlin / dukat

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

Expression extension translation #460

Closed JSMonk closed 2 years ago

JSMonk commented 2 years ago

Summary

Currently, we just ignore any construct signatures and as a result, have a problem with so common declarations like this:

declare interface InstanceApi {
  foo(): void
}

declare interface StaticApi {
  bar(): void
  new(): InstanceApi
}

declare var SomeClass: StaticApi

/* ... */

declare class AnotherClass extends SomeClass {}

I proposed to analyze interfaces, classes, and type aliases on a construct signature existence and generate classes like this:

external interface InstanceApi {
  fun foo()
}

external interface StaticApi {
  fun bar()
}

external class SomeClass: InstanceApi {
  companion object : StaticApi
}

/* ... */

external class AnotherClass : SomeClass

Related Issue

https://github.com/Kotlin/dukat/issues/404

JSMonk commented 2 years ago

Oh, sorry. Seems like I forgot to add it to the git index.