Skip to content

Type inference infers wrong type with extra elements of tuples #22563

Closed
@falsandtru

Description

@falsandtru

separated from #22432

TypeScript Version: 2.7.0-dev.20180307

Search Terms:

Code

type B<R, S> = [R] | [R, S];
declare function g<T, U>(f: B<T, U>): void;
g([[]] as [void[]]); // U: {}

type C<R, S> = [R[]] | [R[], S];
declare function h<T, U>(f: C<T, U>): void;
h([[]] as [void[]]); // U: void[] | ConcatArray<void[]>

Expected behavior:

h([[]] as [void[]]); // U: {}

Actual behavior:

h([[]] as [void[]]); // U: void[] | ConcatArray<void[]>

Playground Link:

Related Issues:

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