type alias
A name given to any type with the type keyword, such as type HttpMethod = "GET" | "POST".
In more detail
Unlike interfaces, type aliases can name unions, tuples, primitives, mapped types and conditional types. They are closed: declaring the same name twice is an error. A common rule is interfaces for public object contracts and type aliases for everything else.
Related terms
- interface (TypeScript) — In TypeScript, a named description of an object's shape: which properties it has and their types.
- union type — A type that allows one of several listed types or values, written with a vertical bar, such as int | None in Python or "small" | "large" in TypeScript.
- tuple — An ordered, fixed-length group of values in which each position can have its own meaning and type.
Taught in
- never: The Bottom Type And Exhaustive Switch Checking — Production TypeScript
- Type Aliases Versus Interfaces: Declaration Merging — Production TypeScript
- Tuples: Fixed Length, Labeled Elements And Variadic Tuples — Production TypeScript
- The in Operator And Instanceof Narrowing — Production TypeScript
- Generic Interfaces, Classes And Type Aliases — Production TypeScript
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript
- Declaration Files, Ambient Namespaces And Module Augmentation — Production TypeScript