I want to extract all unique properties from an array of objects, you can do this in ES6 very simply using the spread operator and Set so:
var arr = [ {foo:1, bar:2}, {foo:2, bar:3}, {foo:3, bar:3} ] const uniqueBars = [... new Set(arr.map(obj => obj.bar))]; >> [2, 3]
However, in TypeScript 1.8.31 this gives me a build error:
Unable to find Install Name
I know that I can make VS ignore it using
declare var Set;
But I hope something TypeScript will compile in non-ES6 so that it can be used on older systems.
Does anyone know if there is such an opportunity that I could use?
Edit
In fact, even when I use declare var Set; , the above code compiles, but repeatedly repeats this error, so I'm not sure how to use it even without compilation:
Uncaught TypeError: (intermediate value) .slice is not a function
How can I update my code to use Set in TypeScript?
source share