Skip to content Skip to sidebar Skip to footer

Can JavaScript/TypeScript Re-export All Named Exports Under An Alias Without Importing First?

Is there any way to do something like the following? export * as MyAlias from 'path/to/somewhere'; I know it's possible to import everything first and then export it, but I would

Solution 1:

I would suggest you usage of named exports. It can be used like this:

import * as ABC from 'path/to/somewhere';
export { ABC as MyAlias };

There is second option that will work as expected:

import * as ABC from 'path/to/somewhere';
const MyAlias = ABC;

export default MyAlias;

Post a Comment for "Can JavaScript/TypeScript Re-export All Named Exports Under An Alias Without Importing First?"