Curriculum
Course: TypeScript
Login
Text lesson

TS Simple Types

TypeScript supports several basic (primitive) types that you might already be familiar with.

JavaScript and TypeScript have three primary primitive types:

  • boolean – Represents true or false values
  • number – Includes both whole numbers and floating-point values
  • string – Represents text values, such as “TypeScript Rocks”

There are also two less common primitives introduced in later versions of JavaScript and TypeScript:

  • bigint – Handles whole numbers and floating-point values, supporting larger positive and negative numbers than the number type.
  • symbol – Used to create globally unique identifiers.

Type Assignment

When defining a variable, TypeScript assigns types in two main ways:

  • Explicitly
  • Implicitly

In both examples below, firstName is of type string.

Explicit Type

Explicit – specifying the type directly:

let firstName: string = “Dylan”;

Explicit type assignments are clearer and more deliberate.