Getting Started with TypeScript

10 April 2024

4 min read

A basic primer for adding TypeScript to your JavaScript projects.

Why Use TypeScript?

TypeScript is a superset of JavaScript that adds static typing. It helps catch errors early and improves code maintainability.

Installation

npm install typescript --save-dev

Basic Usage

Create a file with the .ts extension and write TypeScript code:

let message: string = 'Hello, TypeScript!';
console.log(message);

Compile with:

tsc filename.ts

TypeScript prepares you for scalable and error-free JavaScript projects.