Skip to content

rest parameter not inferred as tuple from contextual type #25289

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
ajafff opened this issue Jun 28, 2018 · 1 comment
Closed

rest parameter not inferred as tuple from contextual type #25289

ajafff opened this issue Jun 28, 2018 · 1 comment
Assignees
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Jun 28, 2018

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:

@mhegazy mhegazy added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Jun 28, 2018
@ahejlsberg ahejlsberg self-assigned this Jul 2, 2018
@ahejlsberg ahejlsberg removed the In Discussion Not yet reached consensus label Jul 2, 2018
@ahejlsberg
Copy link
Member

Agreed, we should infer a tuple type in both cases above.

@ahejlsberg ahejlsberg added this to the TypeScript 3.0 milestone Jul 2, 2018
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Jul 3, 2018
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 Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants