Search code examples
javascripttypescriptecmascript-6spread-syntax

Using spread syntax and new Set() with typescript


I am using following code to get unique numbers:

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.