How to export an imported interface with TypeScript?

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.