Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 6 of 56 · Typescript

Type Aliases & Interfaces

Duration: 20 minutes

Type Aliases (type)

type Point = { x: number; y: number };
let p: Point = { x: 1, y: 2 };

Aliasing works for any type, including unions, intersections, and primitive literals.

Interfaces

interface Person {
  name: string;
  age?: number; // optional property
}

const alice: Person = { name: "Alice" };

Extending Interfaces

interface Employee extends Person {
  employeeId: string;
}

const bob: Employee = { name: "Bob", employeeId: "E123" };

Declaration merging

If you declare the same interface twice, they merge:

interface Window { myProp: string; }
interface Window { another: number; }
// Window now has both properties

Info

Use interfaces when you need declaration merging (e.g., augmenting global types). Use type aliases for complex compositions.

Previous: Literal Types & EnumsNext: Functions – Parameter & Return Types