Skip to main content

End of the TypeScript Course

Summary and final challenge

Congratulations! You have completed all 10 modules and 22 lessons of the TypeScript Course — from primitive annotations, interfaces, and discriminated unions to generics, mapped types, typed async concurrency, Result<T, E>, satisfies, and branded types.

TypeScript exercises are type-checked with strict: true and executed live in-browser in a sandboxed Web Worker against real unit tests; you can also open any snippet in the interactive Playground.

01 · Fundamentals of TypeScript

  • : string / : number
  • boolean
  • inference
  • T[]
  • readonly [T, U]

02 · Types and Interfaces

  • interface
  • type alias
  • field?: T
  • union |
  • typeof / switch
  • never

03 · Generics and Functions

  • optional params
  • default =
  • (a, b) => R
  • void
  • <T extends keyof Obj>

04 · Utility Classes and Types

  • class / private
  • readonly
  • implements
  • Partial<T>
  • Pick<T, K>
  • Omit<T, K>

05 · Advanced Types and Guards

  • x is Type
  • asserts x
  • "up" | "down"
  • as const
  • `${A}-${B}`

06 · Conditional and Mapped Types

  • T extends U ? X : Y
  • infer R
  • [K in keyof T]
  • as `get${...}`

07 · Configuration and Integration

  • tsconfig strict
  • noUncheckedIndexedAccess
  • .d.ts
  • declare global

08 · TypeScript Asynchronous & Promise

  • Promise<T>
  • Awaited<T>
  • Promise.allSettled
  • res.json() as unknown

09 · Error Handling, Result Pattern & Architecture

  • catch (err: unknown)
  • err instanceof Error
  • Result<T, E>
  • import type

10 · Modern Strict Patterns & Final Project

  • satisfies
  • as const
  • Branded<T, Tag>
  • end-to-end pipeline

The final challenge, in five steps

Combine what you mastered by building five runtime-verified strict components: generic firstElement<T>, optional-field getSalary, discriminated ApiResponse<T>, TaskManager with Omit<Task, ...>, and custom type guard isAdmin(user).

1 · Generic First Element

Write a generic helper taking T[] and returning the first item or undefined when empty (Module 3).

Exercise#ts.boss.e1
Attempts: 0Loading…

Define generic function firstElement<T>(arr: T[]): T | undefined returning arr[0].

Loading editor…
Show hint

Place <T> after the function name and return arr[0]; to preserve element types.

Solution available after 3 attempts

2 · Optional Employee Salary Helper

Declare Employee with optional salary?: number and getSalary(emp) returning salary or 0 (Module 2).

Exercise#ts.boss.e2
Attempts: 0Loading…

Define Employee (id: number, name: string, salary?: number) and getSalary(emp: Employee): number using nullish coalescing (?? 0).

Loading editor…
Show hint

Optional salary?: number is number | undefined; return emp.salary ?? 0 safely handles missing values.

Solution available after 3 attempts

3 · Discriminated Union API Response

Model ApiResponse<T> as Success<T> | Failure and narrow branches via res.status (Modules 2 & 3).

Exercise#ts.boss.e3
Attempts: 0Loading…

Implement handleResponse<T>(res: ApiResponse<T>): string returning "Data: " + res.data on "success" or "Error: " + res.message on "error".

Loading editor…
Show hint

Checking res.status === "success" automatically narrows res to Success<T>.

Solution available after 3 attempts

4 · TaskManager Class & Omit Utility Type

Derive NewTask = Omit<Task, "id" | "completed"> and implement TaskManager conforming to ITaskManager (Module 4).

Exercise#ts.boss.e4
Attempts: 0Loading…

Define type NewTask = Omit<Task, "id" | "completed">; then implement TaskManager with private tasks: Task[] = [] and private nextId: number = 1.

Loading editor…
Show hint

Inside addTask(task: NewTask), assign id: this.nextId++ and completed: false, push to this.tasks, and return newTask.

Solution available after 3 attempts

5 · Custom Type Guard & Access Control

Write type predicate isAdmin(user: User): user is Admin and consume it inside getDashboardAccess (Module 5).

Exercise#ts.boss.e5
Attempts: 0Loading…

Implement isAdmin returning user.role === "admin", then implement getDashboardAccess returning "Admin Access: " + permissions or "Standard Access for " + username.

Loading editor…
Show hint

The predicate return type : user is Admin lets TypeScript narrow user inside if (isAdmin(user)).

Solution available after 3 attempts

Full Cheatsheet (13 Sections)

One structured page covering basics, generics, mapped types, strict async/await, Result<T, E>, satisfies, and tsconfig flags.

Open cheatsheet

What now?

Hands-on practice locks in type-level thinking. Launch the live TypeScript Playground to compile strict code in-browser or prototype real pipelines.