Skip to content

Type comparison incorrect with inherited string literals #13985

Description

TypeScript Version: 2.2.0

Code

class Foo {
    bar: "boop";
}
class Buzz extends Foo {
    bar = 'boop'
}

Playground Link

Expected behavior:

Compiles without error.

Actual behavior:

Class 'Buzz' incorrectly extends base class 'Foo'.
  Types of property 'bar' are incompatible.
    Type 'string' is not assignable to type '"boop"'.

Apologies if I'm missing something obvious, this is by design, or there are existing issues for this. I searched and didn't find anything like it.

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