Categories
TypeScript Answers

How to create enum like type in TypeScript?

Spread the love

Sometimes, we want to create enum like type in TypeScript.

In this article, we’ll look at how to create enum like type in TypeScript.

How to create enum like type in TypeScript?

To create enum like type in TypeScript, we can use the enum keyword.

For instance, we write

enum Fruit {
  APPLE,
  ORANGE,
}

to create the Fruit enum with the APPLE and ORANGE values.

Conclusion

To create enum like type in TypeScript, we can use the enum keyword.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *