Skip to content

Literal type initialization with inheritance #10484

Description

@jods4

TypeScript Version: nightly (2.1.0-dev.20160822)

Code

class A {
 protected x: "a" | "b";
}

class B extends A {
  protected x = "b";
}

Expected behavior: Should compile without error. Code seems intuitive to me.

Actual behavior: error TS2415: Class 'B' incorrectly extends base class. Type 'string' is not assignable to type '"a" | "b"'.

Activity

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

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions