Skip to content

Fails to get contextual type for string literal in array #19837

Closed
@ghost

Description

TypeScript Version: 2.7.0-dev.20171108

Code

const x: 'a' | 'a'[] = ['a'];

Expected behavior:

No error.

Actual behavior:

src/a.ts(1,7): error TS2322: Type 'string[]' is not assignable to type '"a" | "a"[]'.
  Type 'string[]' is not assignable to type '"a"[]'.
    Type 'string' is not assignable to type '"a"'.

Was broken by #19733 -- verified by testing with its merge commit and with the previous commit. @weswigham
Detected by running DefinitelyTyped tests.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHigh Priority

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions