vs. unknown
any
- Variables of type
anycan be assigned any value[ - You can perform any operation on
anywithout type checks[ - Compatible with all other types in TypeScript[
unknown
- Variables of type
unknowncan also be assigned any value - You must perform type checks or type assertions before using
unknownvariables - Not compatible with other types without type narrowing or assertion