Permissive or incorrect types
Reasonably often, you will be asked to integrate a library that does not include TypeScript declarations or develop a new feature from scratch. Initially, you will be tempted to do integrate such libraries when defining objects and classes and try to make things work, avoiding spending more time on precisely defining the types they use. This could lead to cases where TypeScript will not type check your code correctly or apply the wrong checks.
Here, we explain the most obvious uses of permissive or incorrect types:
any
: Theany
type is equivalent to opting out of type checking. This means the compiler will not check the type of the variable or parameter and it will pass it on as it is. Usingany
as a type is not recommended as you'll lose all security and features of the type system.Function
:Function
is a generic container type that represents any function type. This is an example of a permissive type, asFunction
can be any kind...