TypeScript supports several basic (primitive) types that you might already be familiar with.
JavaScript and TypeScript have three primary primitive types:
There are also two less common primitives introduced in later versions of JavaScript and TypeScript:
When defining a variable, TypeScript assigns types in two main ways:
In both examples below, firstName is of type string.
Explicit – specifying the type directly:
let firstName: string = “Dylan”; |
Explicit type assignments are clearer and more deliberate.