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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.