Like C++, as TypeScript is also an object-oriented programming language, it has types, specifically:
-
Primitive types
-
Object types
It has the usual:
Object types are functions, arrays, classes, etc. Later, you’ll learn how to create custom object types.
There are two main purposes for types in TypeScript:
- Used by TypeScript compiler to analyze code for errors
- Allows you to understand what values are associated with which variables
Summary
- Every value in TypeScript has a type.
- A type is a label that describes the properties and methods that a value has.
- TypeScript compiler uses types to analyze your code for hunting bugs and errors.