Kotlin / dukat

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

Extending Error class #284

Open Schahen opened 4 years ago

Schahen commented 4 years ago

Following code:

export class DateTimeParseException extends Error {
    constructor(message?: string);
}

export class DateTimeException extends Error {
    constructor(message?: string);
}
Error из lib.es5.d.ts
interface ErrorConstructor {
    new(message?: string): Error;
    (message?: string): Error;
    readonly prototype: Error;
}

declare var Error: ErrorConstructor;

is translated to:

external open class DateTimeParseException(message: String = definedExternally) : Error

external open class DateTimeException(message: String = definedExternally) : Error

external interface ErrorConstructor {
    @nativeInvoke
    operator fun invoke(message: String = definedExternally): Error
    var prototype: Error
}

which is actually looks like a regression - Error is not an open class in kotlin so we ban it's extension.