top | item 43187327

(no title)

tyilo | 1 year ago

Seems to also work without any:

    type Values<T extends Record<string | number | symbol, unknown>> = T[keyof T]

discuss

order

epolanski|1 year ago

Sure, there's many other ways to type it, but none adds any kind of additional safety or strictness over Record<any, any> which was my point that `any` is the correct type in many cases, except when it widens a type.

But in my case it's not widening anything, in Record<A, B>, B can already be `any`thing.

People tend to see it as an unsafe escape hatch (which is how it is abused), but it's just a set of all possible types.

pcthrowaway|1 year ago

Note, the type `PropertyKey` is shorthand for `string | number | symbol` in Typescript