Skip to content

Union of tuple types destructures incorrectly #27543

Closed
@osdiab

Description

@osdiab

TypeScript Version: 3.2.0-dev.20181004
Search Terms: union tuple array destructuring
Code

type Unioned = [string] | [string, number]
const ex: Unioned = ["hi"] as Unioned

// unexpected: y is typed as string | number, instead of number | undefined
const [x, y] = ex;

Expected behavior:
y typed as number | undefined

Actual behavior:
y typed as string | number

Playground Link: Playground

Related Issues: Not really

Metadata

Metadata

Assignees

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