TypeScript Primitives: String, Number, and Boolean Type
Last Updated :
09 Sep, 2025
TypeScript provides a set of basic data types that form the foundation for writing reliable and structured code. These primitive types help ensure values are used consistently and correctly in a program.
TypeScript Primitive DataTypes
Similar to JavaScript's mostly used data types TypeScript has mainly 3 primitives
1. String Type
The string data type represents text or sequences of characters. Strings are enclosed in single or double quotes in JavaScript and TypeScript.
Syntax
let variableName: string = "value";
In the above syntax:
- variableName: This is the name of the variable.
- string: This is the type annotation specifying that the variable should store a string.
- "value": This is the initial value assigned to the variable.
Example: In this example, we will learn about string
JavaScript
let gfg: string = "GeeskforGeeks";
console.log(gfg)
Output:

2. Number Type
The number data type represents numeric values, both integers and floating-point numbers.
Syntax
let variableName: number = numericValue;
In the above syntax:
- variableName: This is the name of the variable.
- number: This is the type annotation specifying that the variable should store a numeric value (integer or floating-point).
- numericValue: This is the initial numeric value assigned to the variable.
Example: In this example, we will learn about number
JavaScript
let num: number = 30;
let float: number = 19.99;
console.log(num)
console.log(float)
Output:

3. Boolean Type
The boolean data type represents a binary value, which can be either true or false. It is often used for conditions and logical operations.
Syntax:
let variableName: boolean = true | false;
In the above syntax:
- variableName: This is the name of the variable.
- boolean: This is the type annotation specifying that the variable should store a boolean value, which can be true or false.
- true or false: These are the initial boolean values assigned to the variable
Example: In this example, we will learn about boolean
JavaScript
let isStudent: boolean = true;
let hasPermission: boolean = false;
console.log(isStudent)
console.log(hasPermission)
Output:
Explore
TypeScript Tutorial
8 min read
TypeScript Basics
TypeScript primitive types
TypeScript Object types
TypeScript other types
TypeScript combining types
TypeScript Assertions
TypeScript Functions
TypeScript interfaces and aliases
TypeScript classes