Syntax

TypeScript Enum Syntax

In TypeScript, enum: defines a set of named constants — enum Color { Red, Green, }

Quick Answer

Syntax
enum Color { Red, Green, }
TypeScriptSyntax

Enum

Code example
enum Color { Red, Green, }

Defines a set of named constants.

Learn More

How to enum in TypeScript

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

TypeScript Enum Syntax

Use enum Color { Red, Green, }.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for enum?

Use this pattern: enum Color { Red, Green, }

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