Closed WillsonSmith closed 7 years ago
160+ instances of this when decaffing app/assets/javascripts/**/*.coffee
😬 At the very least, we should add an esify warning.
@lemonmade this seems like an esify blocker. Should we:
decaf
to add || {}
to any Object.keys
/Object.entries
calls in for for/of
loopsfor/of
loopsshopify-codemod
to figure out loops with potential null references and add fallback valuesYes, I agreed, we need to fix. Are we even converting to something equivalent? Object.entries()
is only over own properties, it looks like CS does it over all properties?
We might want to just match the simpler for in
loop directly from CS, unless that violates some linting rule I don't remember. If so, I would just stick to || {}
.
Right now when translating a
for of
coffeescript loop, we useObject.entries(object)
so:becomes
This assumes that
this.selectedShipmentOptions[this.rateCode]
is defined, but that is not always the case. Since this is how it is translated,Object.entries(undefined)
throws. I can get around it by doing something like:but ideally this wouldn't be necessary.
@GoodForOneFare