Skip to content

Allow Default Values for String Literal TypesΒ #7223

Closed
@blink1073

Description

@blink1073

TypeScript Version:

1.8.2.

Code

// A self-contained demonstration of the problem follows...
class Foo {
    bar: "fizz" | "buzz";
}

class Bar extends Foo {
    bar = "fizz";
}

Expected behavior:
Bar.bar is initialized to "fizz";

Actual behavior:
Type 'string' is not assignable to type '"buzz"'

Metadata

Metadata

Assignees

Labels

In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions