TypeScript


Back to Tags

TS Utility: Extract

🗓️ July 29, 2022

TypeScript has a handy utility type to extract types from a union type 🤭.

  type MyUnion = "Hello" | "Mom" | "I" | "Love" | "You"
  type WithoutMom = Extract<MyUnion, "Mom">
  // the above will be the type "Hello" | "I" | "Love" | "You"
``


export const _frontmatter = {"title":"TS Utility: Extract","date":"2022-07-29T00:00:00.000Z","tag":"TypeScript"}