Coder Social home page Coder Social logo

Comments (4)

ryansolid avatar ryansolid commented on June 1, 2024 1

To be fair the props object itself being optional probably not terribly common, but I could see some deeper object having this issue. But yeah.. the whole expression doesn't get processed it looks like. Compiler issue. Thanks.

from solid.

danieltroger avatar danieltroger commented on June 1, 2024

Yeah I didn't realise that I probably don't need the optional chaining there? But some error message made me add it in my code (adding it made the error go away) and then refs stopped working which sent me on another debugging journey I would have preferred to not be on

from solid.

SarguelUnda avatar SarguelUnda commented on June 1, 2024

I think I narrowed where the bug is but I don't know how to fix it:

https://github.com/ryansolid/dom-expressions/blob/ac40fb85d27d119ee940d3f555e668ebaeaea22f/packages/babel-plugin-jsx-dom-expressions/src/dom/element.js#L468

t.isLVal(value.expression) return true for props.ref but false for props?.ref

t.isOptionalMemberExpression return true for props?.ref but if I try to pass it in the if statement it bugs with

Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "OptionalMemberExpression"

I don't know anything about babel so I'm not sure how to transform a OptionalMemberExpression in MemberExpression

from solid.

mdynnl avatar mdynnl commented on June 1, 2024

pretty close.

props?.ref isn't a LHS value i.e. we can't do props?.ref = node unlike member expr props.ref. same for props.a?.b, hello(), cond ? c : d, or any expression that isn't literal or member can potentially return a function so the correct transform is

const $ref = props?.ref
typeof $ref === 'function' && use($ref, node)

from solid.

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.