Labs ICT
โญ Pro Login

Types

1 min read | TypeScript Tutorial
โญ

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

TypeScript gives you precise control over what your variables can hold. Think of types as contracts you create with your code - you're telling TypeScript exactly what shape the data should take. This prevents those annoying runtime bugs where a number suddenly becomes a string when you least expect it.

Primitive Types

TypeScript comes with a set of built-in primitive types. `string` holds text, `number` holds numeric values, `boolean` holds true/false values, `null` and `undefined` represent emptiness, and `void` represents no return value. These are the basic building blocks of any TypeScript program.


let name: string = "John";
let age: number = 30;
let isActive: boolean = true;
let nullValue: null = null;
let undefinedValue: undefined = undefined;
let noReturn: void = undefined;

// Arrays
let fruits: string[] = ["apple", "banana", "cherry"];
let scores: number[] = [85, 90, 95];

// Tuples (fixed-length arrays)
let person: [string, number] = ["Alice", 25];
    

๐Ÿงช Quick Quiz

What is the TypeScript type for a string value?