7 ms·
> 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 ty
by matt_kantor 2y ago
> 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 https://en.wikipedia.org/wiki/Top_type
[1]: https://tsplay.dev/mA9vXm https://tsplay.dev/mA9vXm
[2]: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any https://www.typescriptlang.org/docs/handbook/2/everyday-type...
- epolanski 2y agoYour 1 isn't equivalent to my example, line 11 is not constraining the type.
- matt_kantor 2y agoI know it's not equivalent, it was just an example to show what `any` does (and that it's more than "just a set of all possible types"). 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"?
- epolanski 2y agoIt works differently based on where those anys are and what that Record<any, any> refers to due to type variance.
- undebuggable 2y agoIt's a "null" and "undefined" discussion all over, but now with transpiler.