Playground with example here: https://tinyurl.com/5ahs366a
This is perfectly sound and valid from both a practical and theoretical pov.
Which is why I was pointing out that there are scenarios like constraints where any not only makes sense but is the correct type.
type Values<T extends Record<string | number | symbol, unknown>> = T[keyof T]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.
`unknown` is the set of all possible types (it's the top type[0]). `any` goes beyond that—it basically turns off the type checker[1][2].
[0]: https://en.wikipedia.org/wiki/Top_type
[1]: https://tsplay.dev/mA9vXm
[2]: https://www.typescriptlang.org/docs/handbook/2/everyday-type...
The `T extends Record<any, any>` on line 11 is a type parameter constraint though. Are you referring to something else when you say "constraining the type"?
[1] https://www.typescriptlang.org/docs/handbook/2/everyday-type...
[2] https://www.typescriptlang.org/docs/handbook/release-notes/t...
https://www.totaltypescript.com/any-considered-harmful#type-...
I've got an issue open about TypeScript's provided `ReturnType` type which is somewhat related to this[1].