bjrnt
bjrnt

Reputation: 2822

Re-export as default in TypeScript

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;

Upvotes: 5

Views: 3304

Answers (2)

pvolok
pvolok

Reputation: 204

You can do it like this:

export { default } from './validators';

Upvotes: 16

basarat
basarat

Reputation: 276199

combine the following two statements into one

No. You need two statements.

Upvotes: 2

Related Questions