Last updated: Apr 29, 2026

Interfaces

Quick-return cheat sheet for TypeScript interfaces — shapes, extensions, generics, overloads, and implementation.

Interface Shape

interface Config {
  host: string;
  port: number;
}

interface AppConfig extends Config {
  /** Shown in IDE hover — use JSDoc for context */
  env: string;

  port?: number;

  readonly version: string;

  format: (input: string) => string;
  reset(): void;

  [key: string]: unknown;

  resolve<T extends string>(value: T): T;
}

Overloads, Getter/Setter, Implements

interface Converter<T extends object> {
  convert(input: string): T;
  convert(input: T): string;

  get value(): T;
  set value(v: T | string);
}

class JsonConverter implements Converter<object> {
  convert(input: string): object;
  convert(input: object): string;
  convert(input: string | object) {
    /* ... */
  }

  get value(): object {
    /* ... */
  }
  set value(v: object | string) {
    /* ... */
  }
}