• 
      

    Remove the newly-added allowDeclaredFields setting for Babel.

    Review Request #14406 — Created April 28, 2025 and submitted

    Information

    Review Board
    release-7.1.x

    Reviewers

    I recently added allowDeclaredFields so that I could utilize the
    declare modifier for variables. However, with Babel, this isn't what
    we want.

    Normally, any variable defined in a class but not set to a value will be
    simply left out of the prototype (an implicit undefined), but with
    this setting enabled, only variables with declare will be left out
    (everything else will be set to an explicit undefined).

    That breaks checks like this.prototype.hasOwnProperty(...) that should
    have been false if a variable was not explicitly set.

    We can instead avoid declare and just define it, getting the same
    results. This only really matters to us today for static variables
    promoted to prototype attributes through Spina.

    Rebuilt all static media and verified the breakages in unit tests have
    been fixed.

    Summary ID
    Remove the newly-added allowDeclaredFields setting for Babel.
    I recently added `allowDeclaredFields` so that I could utilize the `declare` modifier for variables. However, with Babel, this isn't what we want. Normally, any variable defined in a class but not set to a value will be simply left out of the prototype (an implicit `undefined`), but with this setting enabled, only variables with `declare` will be left out (everything else will be set to an explicit `undefined`). That breaks checks like `this.prototype.hasOwnProperty(...)` that should have been `false` if a variable was not explicitly set. We can instead avoid `declare` and just define it, getting the same results. This only really matters to us today for static variables promoted to prototype attributes through Spina.
    ab56bb999c5701d7980d05b06cbcd4a61d16a73a
    Description From Last Updated

    Will there be a corresponding change where we get rid of the declare usage?

    maubinmaubin
    david
    1. Ship It!
    2. 
        
    maubin
    1. 
        
    2. Show all issues

      Will there be a corresponding change where we get rid of the declare usage?

      1. It's part of a pending change, so I'll remove it from there.

    3. 
        
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-7.1.x (5d3ca62)