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

Spread parameters #79

Open
vjau opened this issue Feb 27, 2016 · 3 comments
Open

Spread parameters #79

vjau opened this issue Feb 27, 2016 · 3 comments
Labels

Comments

@vjau
Copy link

vjau commented Feb 27, 2016

In the book, this code is demonstrated :

function foo(x, y, z) { }
var args = [0, 1, 2];
foo(...args);

This is perfectly valid ES6 code, however AFAIK the TS compiler reports an error per microsoft/TypeScript#5296

@basarat basarat added the bug label Feb 28, 2016
@basarat
Copy link
Owner

basarat commented Feb 28, 2016

It compiles to valid JavaScript, but still reports an error. I might not have run this code sample and assumed it would work based on microsoft/TypeScript#1931 (comment).

I'll fix the docs when I have some time 🌹

@amoskyler
Copy link

amoskyler commented Jun 7, 2016

Oh great, I should have looked through the issues! I left a comment on the gitbooks page earlier last week.

So this compiles correctly, but it's unsupported in ts? I'm imagining that means it just shouldn't be used until it's supported in the ts compiler.

@Kyry11
Copy link

Kyry11 commented Aug 1, 2016

It looks like the only way to use Spread Op in the function call is to have a matching Rest Op in the function declaration. Hopefully, in the future TS will be able to type check spread properly.
I look forward to spreading Tuples into function params 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants