r/javascript • • Aug 27 '18

`export default` considered harmful

https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
32 Upvotes

43 comments sorted by

View all comments

35

u/dassurma Aug 27 '18 edited Aug 27 '18

As others have already pointed out, a lot of this is a (valid) complaint about tooling. A couple of remarks I do have, though:

  • Adding named exports: If you started with a default export, and want to export more, the import syntax can accommodate you quite easily: Go from import theDefault from "./module.js"; to import theDefault, {namedExport1, namedExport2} from "./module.js";

  • Re-exporting: Note that you can do export {default} from "./module.js"; or even rename exports export {default as nowWithName} from "./module.js";