any: magic, ill-behaved type that acts like a combination ofnever(the proper [bottom type]) andunknown(the proper [top type])- Anything except
neveris assignable toany, andanyis assignable to anything at all. - Identities:
any & AnyTypeExpression = any,any | AnyTypeExpression = any - Key TypeScript feature that allows for [gradual typing].
- Anything except
unknown: proper, well-behaved [top type]- Anything at all is assignable to
unknown.unknownis only assignable to itself (unknown) andany. - Identities:
unknown & AnyTypeExpression = AnyTypeExpression,unknown | AnyTypeExpression = unknown
- Anything at all is assignable to
- Prefer over
anywhenever possible. Anywhere in well-typed code you're tempted to useany, you probably wantunknown.
