Special Types
TypeScript has several special types that handle edge cases and
specific scenarios: any, unknown, void,
never, null, and undefined.
The any Type
The any type disables type checking - use sparingly!
Output
Click Run to execute your code
The unknown Type
The unknown type is type-safe alternative to any:
Output
Click Run to execute your code
The void Type
The void type means "no return value":
Output
Click Run to execute your code
The never Type
The never type represents values that never occur:
Output
Click Run to execute your code
null and undefined
TypeScript has separate types for null and undefined:
Output
Click Run to execute your code
Summary
any- Disables type checking (use sparingly)unknown- Type-safe version of anyvoid- No return valuenever- Values that never occurnullandundefined- Absence of value
What's Next?
Congratulations! You've completed Module 1. Next, we'll dive into Functions & Interfaces in Module 2!
Enjoying these tutorials?