Git Product home page Git Product logo

Comments (8)

adrianheine avatar adrianheine commented on September 22, 2024

My first guess is that we can only improve this by delaying validation of update and assignment expressions till after we traversed the whole tree. A simpler alternative would be to turn this error into a warning.

from buble.

kzc avatar kzc commented on September 22, 2024

I think the former is the way to go. A warning with false positives is not helpful.

Acorn catches a number of these types of errors doesn't it? If so, maybe this logic is not required at all.

from buble.

adrianheine avatar adrianheine commented on September 22, 2024

Well, I think a warning would be a reasonable approach, exactly because it could be a false positive. Also, a) it is easily fixable b) it is confusing for humans, so fixing it makes sense anyway. But I'm not opposed to the more elaborate and correct solution.

As far as I know acorn doesn't do anything like this, for example it parses const x = 1; ++x.

from buble.

kzc avatar kzc commented on September 22, 2024

The problem is that warnings are almost always ignored by users - even if valid. What's the downside of passing illegal code to Buble as you have above? The generated code will incorrectly behave as if the const is a let?

from buble.

adrianheine avatar adrianheine commented on September 22, 2024

Yes, it will be transpiled to a var. Since most people never run their untranspiled code, this would effectively mean that they can theoretically use const in all kinds of wrong places, ignore the warnings and have incorrect assumptions about their code.

from buble.

kzc avatar kzc commented on September 22, 2024

That doesn't sound desirable - particularly for users like me who never use linters.

from buble.

adrianheine avatar adrianheine commented on September 22, 2024

I actually found an easy solution for this: The checks used to happen in initialise, now I moved them to transpile. I also added them to destructuring assignments.

from buble.

kzc avatar kzc commented on September 22, 2024

@adrianheine Well done! Thanks.

from buble.

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.