|
|
|
|
|
by epolanski
484 days 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. |
|
`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...