Introduction to TypeScript: Where to Start in 2025
TypeScript is a programming language created by Microsoft that extends JavaScript by adding static typing. In 2025, it remains one of the most in-demand tools for developing web applications, server-side solutions, and mobile projects. Whether you're already familiar with JavaScript or just starting your programming journey, TypeScript helps you write more reliable, readable, and scalable code. In this article, we'll break down where to start learning TypeScript in 2025 and show practical examples.
Why choose TypeScript? First, it catches errors at compile time rather than during program execution. Second, it improves autocompletion in code editors. Third, it is actively supported by the community and used in projects like Angular, React, Next.js, and NestJS. Let's dive into the details.
1. Installing and Configuring TypeScript
To get started, you'll need Node.js version 18 or higher. Make sure it's installed by running the command:
node -vIf Node.js is not installed, download it from the official website. Then install TypeScript globally via npm:
npm install -g typescriptVerify the installation:
tsc --versionNow create your first program. Create a file hello.ts:
let message: string = "Hello, TypeScript 2025!";console.log(message);Compile it to JavaScript:
tsc hello.tsAfter that, a file hello.js will appear, which you can run via Node.js:
node hello.jsFor convenience, you can configure the compiler using a tsconfig.json file. Create it with the command:
tsc --initIn it, you can specify settings such as strict type-checking mode, target ECMAScript version, and file paths.
2. Type Basics: From Simple to Complex
TypeScript offers a wide range of data types. Let's start with the basics:
- number — numbers (integers and floating-point).
- string — strings.
- boolean — logical values (true/false).
- null and undefined — empty values.
- any — any type (use with caution).
Example of declaring variables with types:
let age: number = 25;let name: string = "Anna";let isStudent: boolean = true;let data: any = "can be anything";More interesting types are arrays and tuples:
let numbers: number[] = [1, 2, 3];let pair: [string, number] = ["year", 2025];Enums (enum) are also important:
enum Direction { Up = "UP", Down = "DOWN", Left = "LEFT", Right = "RIGHT"}let move: Direction = Direction.Up;In 2025, literal types and union types are actively used. They allow you to specify an exact value or a combination of multiple types:
let status: "active" | "inactive" = "active";let id: number | string = "ABC123";3. Functions, Interfaces, and Classes
TypeScript strictly types functions. You can specify the types of parameters and the return value:
function greet(name: string): string { return `Hello, ${name}!`;}console.log(greet("World"));To describe the structure of objects, use interfaces:
interface User { id: number; name: string; email?: string; // optional field}const user: User = { id: 1, name: "Ivan" };Classes in TypeScript work like in ES6+, but with additional