type ID = string creates an alias. Unlike interfaces, aliases can name unions, tuples, and mapped types.
interface vs type
Use interfaces for object contracts you may extend; use type aliases for unions and utility compositions.
Composition patterns
Aliases shine for unions of interfaces, mapped types, and conditional types—patterns interfaces cannot express. Brand types (type UserId = string & { __brand: 'UserId' }) are an advanced pattern to prevent mixing IDs.
Self-check
- Model
Result<T>as success | failure with a literalokfield.
Practice: Apply type-aliases in the playground, then explain type aliases in one sentence without looking at notes.