Skip to content

rest parameter not inferred as tuple from contextual type #25289

@ajafff

Description

@ajafff

TypeScript Version: 3.0.0-dev.20180628

Search Terms:

Code

declare function take(cb: (a: number, b: string) => void): void;

/*1*/ (function foo(...rest){}(1, ''));
/*2*/ take(function(...rest){});

Expected behavior:

In both functions rest should be inferred as [number, string].

Actual behavior:

1: rest in IIFE is inferred as (string | number)[].
2: rest is inferred as any[] and emits implicit any error.

Related Issues:

Metadata

Metadata

Assignees

Labels

FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions