proposal-shorthand-improvements
proposal-shorthand-improvements copied to clipboard
How would this work with Optional Chaining?
This is a really interesting proposal. But I think we should consider this proposal and its implications on this one. https://github.com/tc39/proposal-optional-chaining
I just worry about safety of accessing deeper properties in objects while defining an object like this.
If no optional chaining is present, and something in the chain is undefined, the entire value becomes undefined, but the key remains the last accessor:
const a = { o.x.z.y.w }
// o.x.z is undefined
// result: a = { w: undefined }
Kind of an implicit optional chaining?
Or, should an error be thrown in this case, because we're accessing y of undefined
?