Does TypeScript have an equivalent of ES6 "Sets" Does TypeScript have an equivalent of ES6 "Sets" typescript typescript

Does TypeScript have an equivalent of ES6 "Sets"


This worked for me.

One of the issues appears to be that typescript trys to use

ERROR TypeError: (intermediate value).slice is not a function

instead of Array.from();

in any event this code worked for me in my Angular 4 applicaiton

Array.from(new Set(Array)).sort(this.compareNumbers)

hope this helps someone


No. If you compile to ES5 or older Typescript only adds the syntactic changes from ES6. It doesn't add any of the standard library objects.

If you want those I suggest you look into something like core.js


You can use this type script library. Or maybe create your one set class using reference from this library