Skip to content

Inheriting constructor through extends clause with a wrapped type argument does not work #1424

Description

The following code should compile just fine, but there is an error when doesNotWork tries to pass this to the constructor for CBase.

class C<T1> extends CBase<T1> {
    public works() {
        new CBaseBase<Wrapper<T1>>(this);
    }
    public doesNotWork() {
        new CBase<T1>(this);
    }

    public method(t: Wrapper<T1>) { }
}

class CBase<T2> extends CBaseBase<Wrapper<T2>> {

}

class CBaseBase<T3> {
    constructor(x: Parameter<T3>) { }
}

class Parameter<T4> {
    method(t: T4) { }
}

class Wrapper<T5> {
    property: T5;
}

Activity

  1. RyanCavanaugh commented on Jan 21, 2015

    @RyanCavanaugh
    Member

    Re [Breaking Change] -- when did this last work? It's an error in 0.9, 1.0, 1.1, and 1.3.

  2. JsonFreeman commented on Jan 21, 2015

    @JsonFreeman
    ContributorAuthor

    Daniel Rosenwasser (@DanielRosenwasser), I do not understand your example. How could those constructor calls work, if the constructor takes a Parameter? C<number> is not a Parameter because it is missing method.

    Ryan Cavanaugh (@RyanCavanaugh), I did not realize that. There was a user on 1.0, and they claimed to hit it on upgrade to 1.4 directly from 1.0.

  3. DanielRosenwasser commented on Jan 21, 2015

    @DanielRosenwasser
    Member

    Ah, disregard my comment.

  4. RyanCavanaugh commented on Jan 21, 2015

    @RyanCavanaugh
    Member

    Might be a more specific repro required to not error in 1.0. Removing tag for now.

  5. modified the milestones: TypeScript 1.6, on May 7, 2015
  6. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions