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

29

u/ryansmith94 Aug 27 '18

Interesting post, good to hear other people's opinions on this. Personally felt the "considered harmful" title was a little over the top, but I do use export default almost exclusively in TypeScript, unless I'm exporting interfaces or constants.

Like you, the CommonJS interop is a concern of mine, but with TS I'm compiling it down to ES5 so it's not an issue. The remainder of your issues seem to boil down to the need for additional syntax in places and poor tooling, not a lot you can do about the syntax at this point, but VS Code provides great tooling that's improving all the time, especially around the usage of default exports.

Whilst I don't agree with the title and don't think this post should put anyone off using default exports, some of the concerns here are certainly good to consider for people using default exports, so nice work 👍

29

u/[deleted] Aug 27 '18

Personally felt the "considered harmful" title was a little over the top

Considered harmful

It's become a meme by this point

0

u/[deleted] Aug 27 '18

[deleted]

1

u/13steinj Aug 27 '18

Can't tell if you're joking or not but yeah it's a thing