Zest.

TypeScript: Interface vs type

A short, tested TypeScript example for interface vs type. Copy it and adjust the names and paths for your project.

TypeScript
interface User {
  id: number;
  name: string;
  email?: string;       // optional
}

type Id = string | number;
type Admin = User & { role: "admin" };

Find it in Zest

Search for “typescript interface vs type” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More TypeScript examples

All TypeScript examples