Web Developer

|

Stockholm, Sweden

Crafting digital experiences where precision meets creativity

The type alias

Mon, 19th Feb 2024

The type alias

You can create a custom name for a type using a type alias. Here's an example where we create our own type alias for the union type string | number:

ref imgage

We completely decide on the name StringOrNumber. We could have chosen any other name.

Using UpperCamelCase (also known as PascalCase) as a naming convention for type aliases is recommended.

The syntax is the keyword type followed by any name you would like, then an = (equal sign), and then the type you'd like to represent.

type alias reference
Benefits
  • it's useful when the same type is repeated.
  • This also improves your editor autocomplete experience as the editor will show you the descriptive name that you chose; for example, StringOrNumber when writing the parameter for convertNumber.

About

4 years of web development
and digital design experience.

Technical

Built with Next.js and TypeScript, styled with Tailwind CSS, powered by Sanity CMS.

Contact

Stockholm, Sweden
Available for projects

© 2025 Harry Yates. All rights reserved.