Categories
TypeScript Answers

How to export an imported interface with TypeScript?

Spread the love

Sometimes, we want to export an imported interface with TypeScript.

In this article, we’ll look at how to export an imported interface with TypeScript.

How to export an imported interface with TypeScript?

To export an imported interface with TypeScript, we can use the export keyword.

For instance, we write

export { default as MessageBase } from "./message-base";

to export the MessageBase module as a default export.

We can export a member from a module by writing

export { IMessage } from "./message-types";

We export the IMessage interface from the ./message-types module.

Conclusion

To export an imported interface with TypeScript, we can use the export 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 *