Skip to content

contextually typing IIFE parameters doesn't work with tuple spread in arguments #25288

@ajafff

Description

@ajafff

TypeScript Version: 3.0.0-dev.20160628

Search Terms:

Code

declare var tuple: [number, string];
(function foo(a, b){}(...tuple));

Expected behavior:

No error.
a is inferred as number
b is inferred as string

Actual behavior:

a is inferred as string | number
b is inferred as undefined
Error Argument of type 'string' is not assignable to parameter of type 'undefined'.

Playground Link:

Related: #24897

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