TypeScriptTypeScript22 min read

TypeScript Type Aliases Power

Master type aliases: unions, intersections, and building expressive domain types.

David Miller
November 18, 2025
4.2k132

Type aliases let you name any type, not just objects.

      ## Union types
      ```ts
      type Status = "loading" | "success" | "error";
      
      let state: Status = "loading";
      ```
      
      ## Intersection types
      ```ts
      type A = { id: number };
      type B = { name: string };
      
      type AB = A & B;
      const obj: AB = { id: 1, name: "Tom" };
      ```
      
      ## Alias for functions
      ```ts
      type Logger = (msg: string) => void;
      
      const log: Logger = (m) => console.log(m);
      ```
      
      ## Domain modeling example
      ```ts
      type UserId = number;
      type Email = string;
      
      type User = {
        id: UserId;
        email: Email;
      };
      ```
      
      ## Graph
      ```mermaid
      flowchart LR
        A[Union] --> B[One of many]
        C[Intersection] --> D[Combine types]
      ```
      
      ## Remember
      - Aliases can represent anything
      - Use unions for choices
      - Use intersections to combine
      
#TypeScript#Advanced#Types