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
.4 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Hmm
How would I type this then
If I wanted the type of
Bar(paramater)
to be 1|2|3
?
keyof typeof this.foo
doesn't workUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
beautiful thanks
One more question - If I want to allow other values as the key, but still want autocomplete is that possible?
something like
T | string
doesn't work
never mind i got it