dukat icon indicating copy to clipboard operation
dukat copied to clipboard

Extending Error class

Open Schahen opened this issue 5 years ago • 0 comments

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.

Schahen avatar May 11 '20 12:05 Schahen