Categories
TypeScript Answers

How to add type aliases with TypeScript?

Spread the love

Sometimes, we want to add type aliases with TypeScript.

In this article, we’ll look at how to add type aliases with TypeScript.

How to add type aliases with TypeScript?

To add type aliases with TypeScript, we can use the type keyword.

For instance, we write

type PrimitiveArray = Array<string | number | boolean>;

to create the PrimitiveArray type with the type keyword which is an array with string, number, or boolean entries.

Conclusion

To add type aliases with TypeScript, we can use the type 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 *