Syntax

TypeScript Define a Type Alias Syntax

In TypeScript, define a type alias: names a type so it can be reused — type ID = string | number;

Quick Answer

Syntax
type ID = string | number;
TypeScriptSyntax

Define a Type Alias

Code example
type ID = string | number;

Names a type so it can be reused.

Learn More

How to define a type alias in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Define a Type Alias Syntax

Use type ID = string | number;.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for define a type alias?

Use this pattern: type ID = string | number;

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify