DEV Community

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

Collapse
 
boywithsilverwings profile image
Agney Menon

I do believe the barrel pattern is useful in some cases. Like say, an API interface, so you can call the APIs with something like api.user.get, so user gets autocomplete on the APIs can narrow down from there. But putting interfaces/components there in the same name can get confusing real quick. With editors like VS Code that support automatic imports, all users would see two imports for this and then might end up picking the wrong one making the barrels kinda useless.

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