Skip to content
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

Contextual typing of spread elements #2172

Closed
JsonFreeman opened this issue Feb 28, 2015 · 2 comments
Closed

Contextual typing of spread elements #2172

JsonFreeman opened this issue Feb 28, 2015 · 2 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@JsonFreeman
Copy link
Contributor

The following gets contextually typed:

var x: ((p: string) => number)[] = [p => p.length];

But the following arguably should also be:

var x: ((p: string) => number)[] = [...[p => p.length]];

Same is true for calls:

function foo(...rest: ((p: string) => number)[]) {}
foo(p => p.length);

So we should do it for the following as well:

function foo(...rest: ((p: string) => number)[]) {}
foo(...[p => p.length]);
@JsonFreeman JsonFreeman added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Feb 28, 2015
@RyanCavanaugh RyanCavanaugh added Declined The issue was declined as something which matches the TypeScript vision and removed In Discussion Not yet reached consensus labels May 4, 2015
@RyanCavanaugh
Copy link
Member

Supported on the grounds of consistency, but at the same time there's no reason to spread a bare literal, so what's the point?

@JsonFreeman
Copy link
Contributor Author

Yeah that makes sense.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants