Giter Site home page Giter Site logo

Comments (16)

xtuc avatar xtuc commented on August 26, 2024 6

I think we came to a conclusion to add braces. I sent a PR and once it's merged we will close this issue. Thanks

from proposal-import-attributes.

littledan avatar littledan commented on August 26, 2024 3

Personally, I'd like to minimize the number of analogous cases we introduce. I think each one adds a bit of confusion. So, I'd prefer to omit the braces.

from proposal-import-attributes.

devsnek avatar devsnek commented on August 26, 2024 3

there'd likely be a comma there:

import { foo } from 'foo.js' with type: "json",
  foobar: "baz";

from proposal-import-attributes.

bmeck avatar bmeck commented on August 26, 2024 2

I think the argument for wanting braces/adding familiarity of syntax is less compelling if the non-brace syntax still allows copy pasting albeit requiring a wrapping {/*paste here*/}. I'm fine on either, just pointing out that the usability concern of braces enhancing copy/paste between locations seems somewhat weak.

from proposal-import-attributes.

littledan avatar littledan commented on August 26, 2024 2

Personally, I still prefer the no-brackets notation, but I'm open to using the brackets here.

I'd like to propose that, while the choice of a key-value notation is pretty core for Stage 2, the question of whether or not we use brackets is a more detailed/superficial decision, which we could continue debating and conclude for Stage 3. Do folks agree?

from proposal-import-attributes.

gibson042 avatar gibson042 commented on August 26, 2024 2

In addition to having nice symmetry for import expressions, I believe braces or other delimiters are actually required to preserve future potential for solving things like #56 (i.e., the trailing comma case mentioned above). The no-braces syntax cuts off too much IMO.

from proposal-import-attributes.

gibson042 avatar gibson042 commented on August 26, 2024 2

I don't think the question of braces vs. no braces should block Stage 2.

from proposal-import-attributes.

chicoxyzzy avatar chicoxyzzy commented on August 26, 2024 2

No-braces syntax could be even more confusing. Also we already use curly braces in imports and they are not an object destructuring.

from proposal-import-attributes.

chicoxyzzy avatar chicoxyzzy commented on August 26, 2024 1

I'm in favor of this. I agree with @justinfagnani on readability. Besides that (as I mentioned in #3), this look pretty similar to dynamic import variant and if attributes line is very long, than multiline attributes should be considered.They look better with curly braces (this also makes trailing comma possible).

from proposal-import-attributes.

jridgewell avatar jridgewell commented on August 26, 2024 1

There's an ASI hazard without braces:

import { foo } from 'foo.js' with type: "json"
  foobar: "baz";

labels (while rare) can't be differentiated. Is it supposed to be { type: "json", foobar: "baz"} or { type: "json" }; foobar: "baz" (a labeled string statement).

If we consider this to be arbitrary metadata proposal, it becomes more likely that we'll have multi-line metadata, making this more likely to hit.

from proposal-import-attributes.

littledan avatar littledan commented on August 26, 2024 1

@gibson042 I guess I'm still not convinced that we shouldn't solve that within the key/value-only syntax. Nevertheless, I'm not extremely against brackets, it's more of a minor preference.

Do you think we need to resolve this brackets-or-no-brackets question before Stage 2, or can we continue discussing it between Stage 2 and 3?

from proposal-import-attributes.

xtuc avatar xtuc commented on August 26, 2024 1

I don't have a preference for braces vs no braces, but I'm not convinced that braces would address #56.

In general, my understanding is that braces seems to allow better UX because of copy pasting, traling comma or being closer to the dynamic import. My only concern is that the static restriction on value will confuse developers that think it's just an object.

from proposal-import-attributes.

bmeck avatar bmeck commented on August 26, 2024

I think as long as the attributes are able to be wrapped in {} to become an Object literal it seems a fair tradeoff to allow some copy pasting.

from proposal-import-attributes.

littledan avatar littledan commented on August 26, 2024

@bmeck I am trying to understand; does this mean you would be OK both with or without braces?

from proposal-import-attributes.

littledan avatar littledan commented on August 26, 2024

Thanks for clarifying. I think this matches my intuition as well.

from proposal-import-attributes.

jridgewell avatar jridgewell commented on August 26, 2024

Ahhh, you’re right.

from proposal-import-attributes.

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.