-
Notifications
You must be signed in to change notification settings - Fork 75
Should delete a?.b
be allowed or forbidden?
#14
Comments
Deletion is strange enough; I'm not sure why we would want conditional deletion. We shouldn't be striving to add optional chaining everywhere it's possible imo; only where it's useful. |
Agreed with @ljharb .
|
Babel itself could benefit from optional deletion: https://github.com/babel/babel/blob/28ae47a174f67a8ae6f4527e0a66e88896814170/packages/babel-helper-builder-react-jsx/src/index.js#L66-L69 Not every parser adds the |
That there exists a use case isn't necessarily a reason to add the feature :-) |
Thanks for the use case. I expect to provisionally keep the “optional delete” feature when resolving #13 (but this Issue will remain open until a final decision is made). |
After careful consideration, I think that
Or said the other way, forbidding that form, will introduce an inconsistency in the semantics of |
The ongoing refactoring of Issue #20 will imply that optional delete will be implemented even without changing a jot in the current specification of the |
I don't think const o={foo: 1}: o?.foo=undefined; o is not supported as I see But I'd rather not support both of them (#18) |
The right semantics of
delete a?.b
is evident and requires practically zero effort to spec. Should it be allowed or not?The text was updated successfully, but these errors were encountered: