Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-export as default in TypeScript

Tags:

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;
like image 492
bjrnt Avatar asked Dec 24 '22 12:12

bjrnt


2 Answers

You can do it like this:

export { default } from './validators';
like image 144
pvolok Avatar answered Jan 11 '23 17:01

pvolok


combine the following two statements into one

No. You need two statements.

like image 44
basarat Avatar answered Jan 11 '23 19:01

basarat