Re-export as default in TypeScript

Viewed 2032

In TypeScript we can re-export modules in the following way:

export * from './validators'; // Re-export all exports
export { validate as stringValidator } from './validators/string'; // Re-export with changed name

My question is about whether it is possible to re-export as default, e.g. combine the following two statements into one:

import * as validators from './validators';
export default validators;
2 Answers

You can do it like this:

export { default } from './validators';

combine the following two statements into one

No. You need two statements.

Related