Code Monkey home page Code Monkey logo

Comments (2)

bb avatar bb commented on July 17, 2024 1

Thanks for the detailed overview! It was not my intention to trigger that much work with my seemingly small question. Sorry.

To elaborate my vote in favor of named exports, some additional comments:

  • Regarding Pro-default 2

    I think this argument is a bit historic as default was the earlier option. I think this point should be removed from the list or even be moved to the con-default list. Here's why:

    where you can change the name

    You can also rename named exports like e.g. import { instantMeiliSearch as whatIWant } from 'instant-meilisearch'. Refactoring would then rename instantMeiliSearch but not the local name whatIWant.

    Also, given the package is already installed, with Named exports I could just type instantM (or even less), get the autocompletion (from vscode, in my case) which then automatically adds a named import (or extends an existing one, if something else from the package was already imported).

    If I'm missing the import but have a snippet pasted from somewhere like basic usage example from the readme, it would underline the method name and provide the autofix to add a named import. I think it does not do that for default exports (at least it didn't for axios which I just tried it with.)

    Concluding this bullet, I'd consider named exports easier to use than default and would just cross that point from the pro-list.

  • Another con-default:

    If there's a reason later to export another function, this would be very easy with named exports, but not with default exports.

  • Another pro-default:

    • changing it now would be breaking change (but the earlier, the better?)

Here's another list of arguments against default export (some of which have already been mentioned), from @basarat's book TypeScript Deep Dive: https://basarat.gitbook.io/typescript/main-1/defaultisbad

from meilisearch-js-plugins.

bidoubiwa avatar bidoubiwa commented on July 17, 2024

Closed by: #238

from meilisearch-js-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.