Categories
TypeScript Answers

How to import all types with TypeScript?

Spread the love

Sometimes, we want to import all types with TypeScript.

In this article, we’ll look at how to import all types with TypeScript.

How to import all types with TypeScript?

To import all types with TypeScript, we can do a namespace import.

For instance, we write

import * as foo from "./otherClass";

to import all members of the ./otherClass module as foo.

Then we can access any member of it from foo like

foo.bar

where bar is an exported member from ./otherClass.

Conclusion

To import all types with TypeScript, we can do a namespace import.

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 *