-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
Right now when translating a for of coffeescript loop, we use Object.entries(object) so:
for code, option of @selectedShipmentOptions[@rateCode]
rows.push(Shopify.Templates.render(@shipmentOptionsTemplate, {
optionName: option.name,
optionPrice: @money(option.amount)
}))becomes
for (const [code, option] of Object.entries(this.selectedShipmentOptions[this.rateCode])) {
rows.push(Templates.render(this.shipmentOptionsTemplate, {
optionName: option.name,
optionPrice: this.money(option.amount),
}));
}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:
const selectedShipmentOption = this.selectedShipmentOptions[this.rateCode]) || {};
for (const [code, option] of Object.entries(selectedShipmentOption) {
...but ideally this wouldn't be necessary.
Reactions are currently unavailable