Problem Statement
Compare type vs interface with extend/merge examples.
Explanation
Interfaces: great for object shapes and class contracts; they can extend each other and merge across declarations. Types: great for unions/intersections and type transforms. Use interface when you want open, extendable shapes; use type when you need composition like `A | B` or `A & B` or mapped/conditional types.
Code Solution
SolutionRead Only
interface Api { get(id: string): Promise<string> }
interface Api { list(): Promise<string[]> } // merges
// unions/intersections are easier with type
type Id = string | number;
type UserView = { id: string } & { name: string };