Skip to content

Latest commit

 

History

History
76 lines (69 loc) · 2.93 KB

type-alias.md

File metadata and controls

76 lines (69 loc) · 2.93 KB

Type Alias

A type alias is a type that:

  • has its own name,
  • and reuses the definition of an existing type

For example:

type MediaTypeOptions = OnErrorOptions;

With careful use, they bring important benefits.

  • They're often used as a form of documentation, or as an opportunity to write documentation. That's definitely a good thing. We don't believe that code is documentation.
  • They provide a level of future-proofing. As long as developers use them, we can add more fields to MediaTypeOptions without accidentally changing the options to any other functions.
  • But they don't provide two-way isolation. MediaTypeOptions will automatically gain any new fields that we add to OnErrorOptions. That may be an unintended side effect.