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.
'any' has always been intended as an escape hatch, so no abuse here [1]. The type representing the set of all possible values (the top type in the type lattice) is 'unknown'.
epolanski|1 year ago
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.
matt_kantor|1 year ago
`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...
remolueoend|1 year ago
[1] https://www.typescriptlang.org/docs/handbook/2/everyday-type...
[2] https://www.typescriptlang.org/docs/handbook/release-notes/t...
pcthrowaway|1 year ago