I'm migrating a JS codebase to TS. In JS we have some index.js files which reexport all imports from a module:
export * as users from './users';
What's the equivalent TS for this?
Here's a summary of re-export *:
// Re-export *
export * as default from './example1' // as default-import
export * from './example2' // separately
export * as ex3 from './example3' // as a named-object
// usage:
// import ex1, { example2Const, ex3 } from './reexport'
// import * as all from './reexport'
And a reminder of re-export picked:
// Re-export chosen
export { a, b as newB, c as default } from "./example4"; // pick what to export
// usage:
// import c, { a, newB } from './reexport'
// import * as all from './reexport'
Docs:
· Re-export all
· Re-export as named object
I haven't found a way to do this as a single line, but a coworker pointed out this approach can work:
import * as users from './users';
export {
users,
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With