Like C++, as TypeScript is also an object-oriented programming language, it has types, specifically:

  • Primitive types

  • Object types

It has the usual:

string // string 
number // a number
boolean // bool
null // null
undefined // 
symbol // a unique constant value 

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:

  1. Used by TypeScript compiler to analyze code for errors
  2. 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.