TypeScript adds types to JavaScript so many mistakes are caught before your code runs. The basics are quick to learn if you know JavaScript.
Direct answer
To learn TypeScript: learn JavaScript first, add type annotations to variables and functions, learn interfaces and union types, then generics and how it works with your tools. Practise in an online playground or compile files with the TypeScript compiler. The basics take days to a couple of weeks if you know JavaScript.
Basic types
let name: string = "Sam";
let age: number = 30;
let isMember: boolean = true;
let scores: number[] = [10, 20, 30];
TypeScript will warn you if you try age = "thirty".
Functions
function greet(name: string, times: number = 1): string {
return `Hello, ${name}! `.repeat(times);
}
Interfaces
interface User {
id: number;
name: string;
email?: string; // optional
}
const user: User = { id: 1, name: "Sam" };
Union types
function printId(id: number | string) {
console.log(id);
}
Running TypeScript
Browsers can't run TypeScript directly. It's compiled to JavaScript:
- Install Node.js.
- Install TypeScript using the official instructions.
- Write
app.ts. - Compile with
tsc. - Run the output.
Or use an online playground to start.
Topics to learn
- Basic types
- Functions
- Objects and interfaces
- Unions and literal types
- Generics
- Working with libraries and frameworks
How long?
If you already know JavaScript, a couple of weeks of regular practice covers the basics.
Related
TypeScript vs JavaScript and JavaScript for beginners.
Where Teyro fits
Teyro's TypeScript for Beginners course teaches types step by step in 20 short lessons. It is free to start.
The bottom line
Know JavaScript, add types gradually.



