DEV Community

Discussion on: How to add Barrels in TypeScript (or JavaScript)

Collapse
 
fjones profile image
FJones • Edited

Sorta. Don't do that... with a blanket export.

Having an index barrel with all available exports can be very useful for readability and makes it easier to move/rename the implementation files. (Think __init__.py indexes in python.) It also allows for implicit private exports which can be more easily respected by a module consumer.

That said, export * from 'foo' introduces magic that may in fact produce more opaque code instead. Prefer explicitly exporting the relevant symbols as an actual index.

Some comments have been hidden by the post's author - find out more