Skip to content

Union types of tuples and never[] incorrectly mutate into array types #20495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
falsandtru opened this issue Dec 6, 2017 · 1 comment
Closed
Labels
Fixed A PR has been merged for this issue

Comments

@falsandtru
Copy link
Contributor

TypeScript Version: master

Code

const t1 = [0, ''] as [number, string] | undefined || [];
const [a1 = 0] = [0, ''] as [number, string] | undefined || [];
const t2 = [0, ''] as [number, string] | never[];
const [a2 = 0] = [0, ''] as [number, string] | never[];

Both types of t1 and t2 are the same type [number, string] | never[]. But the results of destructuring assignment is different. a1 is number type but a2 is number | string type. a2 should also be number type.

@mhegazy mhegazy added the Needs Investigation This issue needs a team member to investigate its status. label Feb 9, 2018
@RyanCavanaugh RyanCavanaugh added Fixed A PR has been merged for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels Sep 16, 2019
@RyanCavanaugh
Copy link
Member

a2 is now number as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants