Skip to content

(suggestion) Overrides in extending class and interface definitions. #3402

@ttowncompiled

Description

@ttowncompiled

Using this example:

interface A {
  build(): SomeType;
}

interface B extends A{
  build(): SomeOtherType;
}

The compiler will thrown an error that SomeOtherType is not assignable to SomeType. However, if I am holding an object of type B and I call build() on that object, I know that I will receive a value of type SomeOtherType.

I've currently used any as an override, but it would nice to be able to override the return type of functions on a parent class or interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions