Recommended Free Tools
Use array spread to copy a Set’s values into a new array: const values = [...set];. Array.from(set) is an equally useful alternative. Both preserve the Set’s iteration order and let TypeScript infer the element type.
Convert a Set with array spread
const set = new Set(["red", "green", "blue"]);
const values = [...set];
console.log(values); // ["red", "green", "blue"]
A Set is iterable, so array spread reads its values in iteration order and puts them in a new array. The Set itself remains a Set. TypeScript’s handbook demonstrates this general iterable-to-array pattern as [...xs]: Iterators and Generators.
Use Array.from as an alternative
const values = Array.from(set);
Array.from also creates an array from the Set’s iterable values. Choose whichever form is clearer in context: spread is compact, while Array.from makes the conversion explicit.
What happens to types and values?
TypeScript infers the element type
const numbers = new Set<number>([1, 2]);
const values = [...numbers]; // number[]
An empty Set converts to an empty array with either syntax:
#1 Best Overall
const empty = new Set<string>();
const values = [...empty]; // []
The array is a shallow copy of the collection. Adding or removing array elements does not add or remove Set entries, but objects in the Set are shared by reference: changing one of those objects is visible through both containers.
Check compiler and runtime support
TypeScript declarations and runtime support are separate concerns. The lib compiler option determines which built-in API declarations TypeScript knows about; the ES2015 library includes declarations for Map and Set, and lib can be configured independently of target. See the TSConfig reference for lib.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Declarations do not install APIs in the JavaScript environment. The runtime must support Set, iteration, and Symbol.iterator. TypeScript explains the relationship between target and emitted JavaScript, and how default library declarations vary with the target, in its guide to Type Declarations.
When targeting older JavaScript
The TypeScript handbook notes restrictions on using non-array iterables with for...of when targeting ES5. For older targets, downlevelIteration enables more faithful iterator-protocol handling for constructs such as array spread, but it does not supply a missing runtime Symbol.iterator. The runtime must already provide it or have a suitable shim. See the TypeScript 2.3 release notes.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.




