Sitemap

Member-only story

🔍 TypeScript Basics: Types, Interfaces, and Beyond

2 min readMay 27, 2025

--

So you’ve written your first TypeScript file in Article 1: “Why TypeScript? A Beginner’s Guide to Stronger JavaScript”. But what makes TypeScript truly powerful is its type system.

In this article, we’ll cover the foundational elements of TypeScript: primitive types, arrays, functions, interfaces, and more — all explained in simple terms.

Whether you’re coming from JavaScript or just getting started, this guide will help you build confidence writing strongly typed code.

đź§± 1. Primitive Types in TypeScript

TypeScript gives you familiar types, but with explicit declarations.

let firstName: string = "Alice";
let age: number = 30;
let isOnline: boolean = true;

You can also let TypeScript infer the type:

let city = "New York"; // inferred as string

đź§® 2. Arrays, Tuples, and Enums

Arrays

Define arrays with element types:

let fruits: string[] = ["apple", "banana"];
let numbers: number[] = [1, 2, 3];

Or use generic syntax:

let prices: Array<number> = [99.99, 24.5];

Tuples

Fixed-length arrays with specific types for each item:

let person: [string, number] = ["Alice", 25];

--

--