Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

A type alias in TypeScript is a declaration that assigns a custom identifier to a specific type structure. Rather than creating a distinct new type in the type system, it establishes a symbolic name that the TypeScript compiler resolves to the underlying type definition during static analysis.
type Identifier = TypeExpression;
Type aliases can represent any valid TypeScript type expression. This includes primitives, complex object shapes, unions, intersections, tuples, and function signatures.
// Primitive
type UUID = string;

// Object Shape
type Point = {
  x: number;
  y: number;
};

// Union
type State = "pending" | "resolved" | "rejected";

// Intersection
type SerializablePoint = Point & { toJSON(): string };

// Tuple
type Coordinates = [number, number, number];

// Function Signature
type Comparator = (a: number, b: number) => boolean;

Generics

Type aliases fully support generic type parameters, allowing for the creation of parameterized, reusable type definitions. The generic parameters are passed inside angle brackets <> immediately following the alias identifier.
type Result<T, E> = 
  | { success: true; data: T } 
  | { success: false; error: E };

type Dictionary<K extends string | number | symbol, V> = Record<K, V>;

Recursion

Type aliases can be self-referential (recursive) to represent infinitely nested structures. The TypeScript compiler permits this as long as the recursive reference is deferred, typically by being nested within an object property or an array type.
type JSONValue = 
  | string 
  | number 
  | boolean 
  | null 
  | JSONValue[] 
  | { [key: string]: JSONValue };

Structural Constraints

A defining mechanical characteristic of a type alias is that it is closed upon declaration. Unlike interfaces, type aliases do not support declaration merging. Attempting to declare multiple type aliases with the exact same identifier within the same module scope will result in a Duplicate identifier compiler error.
type Entity = { id: string };

// Compiler Error: Duplicate identifier 'Entity'.
// type Entity = { createdAt: Date }; 
Furthermore, when a type alias is used in an error message or IDE hover tooltip, TypeScript will often expand the alias to its underlying type structure, demonstrating that the alias is purely a developer-facing syntactic convenience rather than a nominal type boundary.
Master TypeScript with Deep Grasping Methodology!Learn More