DEV Community

loading...

Discussion on: The "any" type in Typescript - simple and short explanation

Collapse
tkudlinski profile image
Tomasz Kudlinski • Edited

I think it is worth mentioning that where possible, use of any should be avoided. Typescript 3.0 introduced more safe replacement of any called unknown:

unknown is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn’t assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type.

docs about it

Collapse
arikaturika profile image
Arika O Author

True. This is the subject of my next actually :). Thx for mentioning it.