Skip to main content
D
TypeScript
TypeScript Simple Types

TypeScript Simple Types

TypeScript locks variables into specific data types.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

In normal JavaScript, a variable can be a number on line one, and suddenly change to a text string on line two. TypeScript strictly forbids this. Developers use simple primitive types to lock down variables permanently.

Example

Example
1/* this sets primitive types */
2let isDone: boolean = false;
3let score: number = 100;
4let playerName: string = "Alice";

Key Points

  • Use `boolean` for true or false values.
  • Use `number` for decimals or whole numbers.
  • Use `string` for text characters.
  • Add the colon `:` to specify the type.

Up Next

Continue your journey with the next topic.

Go to TS Type Inference