Categories
JavaScript Answers

How to import all types with TypeScript or JavaScript?

Spread the love

Sometimes, we want to import all types with TypeScript or JavaScript.

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

How to import all types with TypeScript or JavaScript?

To import all types with TypeScript or JavaScript, we can use *.

For instance, we write

import * as foo from "./otherClass";

to import all the exported contents as the foo object from the otherClass module.

Then we can use the imports by writing

foo.ClassA

to use ClassA from the otherClass module.

Conclusion

To import all types with TypeScript or JavaScript, we can use *.

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 *