Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
11 replies
6enton

Is it possible to infer a const type from a Set?

Say I have const foo = new Set([1,2,3])
how can I infer the type of foo as const?

For example, const bar = [...foo.keys()] as const is of type
number[]
instead of type 1 | 2 | 3.
Was this page helpful?