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

Set is not an array type #5391

Closed
wmaurer opened this issue Oct 24, 2015 · 3 comments
Closed

Set is not an array type #5391

wmaurer opened this issue Oct 24, 2015 · 3 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@wmaurer
Copy link

wmaurer commented Oct 24, 2015

With Babel, I can use spread syntax on a Set. For example, the following neat trick returns the unique elements in an array:

const a = [ 0, 1, 2, 3, 2, 1, 0];
console.log([...new Set(a)]);

// outputs [0, 1, 2, 3]

However in Typescript, I get the following error: Set is not an array type. I presume this is a problem with the lib.d.ts typings?

BTW, I also tried this on http://www.typescriptlang.org/Playground, but there I got the error: "Cannot find the name 'Set'".
Is the Playground not up to date with the latest tsc version?

@saschanaz
Copy link
Contributor

I think you didn't set the target properly. Try --target ES6.

@wmaurer
Copy link
Author

wmaurer commented Oct 26, 2015

Ok, thanks @saschanaz

@wmaurer wmaurer closed this as completed Oct 26, 2015
@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Oct 26, 2015
@spieIbug
Copy link

tsconfig.json
{ "compilerOptions": { "target": "es6", } }
thank you @saschanaz

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants