Course contentsShow
← TypeScript
Lesson 355 of 1,7968. Interfaces vs Type AliasesFree lesson

Type Aliases Are Not Nominal

Type aliases create structural types; two aliases with identical shapes are interchangeable in TypeScript.

Type Aliases Are Not Nominal

You'll learn: Type aliases in TypeScript create structural types, meaning two aliases with identical shapes are completely interchangeable—names don't matter.

What "Nominal" Means

In nominal type systems, two types are different if they have different names, even if their structure is identical. Think of it like requiring a specific brand of battery—even if a generic battery has the exact same voltage and size, the device won't accept it unless it has the right brand name.

In structural type systems (like TypeScript), types are compatible based on their shape, not their name. If two batteries have identical specifications, they're interchangeable regardless of the label.

TypeScript Uses Structural Typing

When you create type aliases, you're giving a name to a structure—but TypeScript only cares about the structure itself:

type UserID = string;
type ProductID = string;

const user: UserID = "user_123";
const product: ProductID = user; // ✅ Allowed! Both are strings.

Even though UserID and ProductID are semantically different in your domain, TypeScript sees them as identical because they're both just string.

The Same Applies to Object Shapes

type Point2D = { x: number; y: number };
type Coordinate = { x: number; y: number };

const point: Point2D = { x: 10, y: 20 };
const coord: Coordinate = point; // ✅ Perfectly valid

The names Point2D and Coordinate are irrelevant to TypeScript. Since both aliases describe objects with x and y properties of type number, they're structurally identical and fully compatible.

Why This Matters

This behavior prevents you from using type aliases alone to create truly distinct types in your domain. You can't prevent accidentally passing a UserID where a ProductID is expected just by using different alias names.

Key Takeaway: Type aliases are purely structural—two aliases with identical shapes are completely interchangeable, regardless of their names.