Comments (2)
I don't really see any argument that compels me to start using default exports. I like to streamline to just 1 thing way of doing things. More choices to achieve the same thing is never something that appeals me but just makes me worry about "what is the best way" while 9/10 this is useless worry. XD
So I just chose, there's nothing you can't do with named exports, so why not only use named exports. It's all about reducing options and streamlining, unifying, calming the mind. ;)
from is-what.
I am of the opinion that in an ESM world, default exports work well with single-export-per-file conventions.
Remove the ESM-only expectation and transpile to CJS and now you're dealing with the user expecting module.exports = thing
but getting exports.default = thing
which goes haywire very fast. 👈 This is actually a moot (for us) point since we are still going to named export everything, the internals are all ✨ magic transpiled and should match up regardless. It's the other-package imports that get tricksy.
Remove the single file requirement and bundle things into utils-and-more.ts
and you want to know what you're importing.
As for the VS Code tooling support, watch this fancyness!
ezgif-3-91f82fb675.mp4
I get normal satisfactory autocomplete, same as named exports. This may be different or more complicated for CJS projects or other fancy stuff. Default exports do have some hiccups, this is true! Take this:
// Hello.ts
type Hello = string
export type { Hello as default }
☝ You can't type Hello
and hit Enter and have it auto-import the default Hello. I don't know if this is a export type
problem or a as default
problem or what. I just know that this is the only time that I've had issues. 😃 But yes, there are occasional hitches with auto-importing.
from is-what.
Related Issues (20)
- Dual package hazard HOT 4
- Add benchmarks HOT 1
- Add automation HOT 9
- Consider using tsx and node:test? HOT 1
- Better JSDoc with @example HOT 4
- add `isInstanceOf` to readme HOT 1
- [Discussion] Consider ESM-only for v5? HOT 2
- Interested in @tinylibs? HOT 1
- Move FUNDING.yml to .github repo HOT 2
- GitHub Pages site doesn't exist HOT 4
- Add isCallable() and isConstructable() HOT 1
- Consider publishing solely to npm, and recommending Deno use npm:is-what? HOT 2
- [Milestone] v5 HOT 2
- Split src/index.ts into multiple files
- [Discussion] Consider using stricter brand checks than just Symbol.toStringTag? HOT 2
- More edge-case tests HOT 1
- Rename the "production" branch to "main" HOT 1
- Expose individual files as exported files HOT 1
- the isPlainObject can be improved because it has missed Object.create(null) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from is-what.