YouTip LogoYouTip

TypeScript Tutorial - Getting Started

What is TypeScript?

TypeScript adds static typing to JavaScript. It catches errors at compile time.

Basic Types

let name: string = "Alice";
let age: number = 25;
let active: boolean = true;
let items: string[] = ["a", "b"];
let id: string | number = 1;

Interfaces

interface User {
    id: number;
    name: string;
    email?: string; // optional
}
const user: User = { id: 1, name: "Alice" };

Summary

  • TypeScript adds types on top of JavaScript
  • Interfaces define object shapes
← TypeScript Types and GenericsJavaScript DOM Manipulation β†’