// Type aliases create a name for any type expression
Note Type aliases and interfaces overlap for object shapes, but type aliases can also name unions, tuples, primitives, and function types. Unlike interfaces, type aliases cannot be re-declared for merging. Use interfaces for object shapes that might be extended; use type aliases for everything else.
Frequently asked questions
How does Python handle type alias?
This task is covered in 2 stacks on this page: Python, TypeScript. The "Type Aliases (3.12+)" snippet in Python uses `type AliasName = existing_type`.
Which code does the Python example use?
The "Type Aliases (3.12+)" snippet uses `type AliasName = existing_type`, from the Variables & Types section of the Python cheat sheet.
Which stacks cover "type alias" on this page?
Python, TypeScript. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Type Aliases (3.12+)": The type statement (Python 3.12+) replaces TypeAlias from typing. It supports lazy evaluation and generic parameters.