--

Three more negatives of named exports I can think of:

3-- You don't know "by default" what you named a given file, so you have to search for it inside files, instead of just being able to search by file name

4-- Named exports encourage the horrible "index.tsx" import all / export all pattern whereas default exports prevent you from making "index.ts" files everywhere

5-- When I write tests, I always write `describe('@/components/card/Card', () => {` which is effectively assuming a default export.

I make an exception for certain constants and utility functions at times, but I really prefer default exports. I guess the great thing about TypeScript is you can do whatever you want.

--

--

Dr. Derek Austin 🥳
Dr. Derek Austin 🥳

Written by Dr. Derek Austin 🥳

Hi, I'm Doctor Derek! I've been a professional web developer since 2005, and I love writing about programming with JavaScript, TypeScript, React, Next.js & Git.

No responses yet