Skip to content

Enable base class members overriding #2314

Open
@leandropadua

Description

@leandropadua

🚀 Feature Request

As per current state of JSII, there's a limitation regarding overriding base class members.
This is described in the typescript restrictions documentation.

export class Base {
  public method(): any { /* ... */ }
}

export class Child {
  // ⛔️ Illegal change of signature when overriding a member
  public method(): string { /* ... */ }
}

However, c# recently announced covariant returns to enable the specialized class to override the base class method:
https://devblogs.microsoft.com/dotnet/c-9-0-on-the-record/#covariant-returns

If the whole limitation can't be removed, maybe we could at least allow override when the new member type is an extension of the original base member.

Also, I haven't tried myself, but it would be interested to explore if this can also remove the limitation of overriding interface members.

Thank you.

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedWork is blocked on this issue for this codebase. Other labels or comments may indicate why.feature-requestA feature should be added or improved.language/dotnetRelated to .NET bindings (C#, F#, ...)p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions