patternjavascriptMajor
Using spread syntax and new Set() with typescript
Viewed 0 times
typescriptwithandsyntaxsetusingspreadnew
Problem
I am using following code to get unique numbers:
However, typescript report following error: Type 'Set' is not an array type.
I am not typescript ninja, could someone tell me what is wrong here?
let uniques = [ ...new Set([1, 2, 3, 1, 1]) ]; // [1, 2, 3]However, typescript report following error: Type 'Set' is not an array type.
I am not typescript ninja, could someone tell me what is wrong here?
Solution
This is a missing feature. TypeScript only supports iterables on Arrays at the moment.
Context
Stack Overflow Q#33464504, score: 61
Revisions (0)
No revisions yet.