feat: add optional chaining (?.) support 🔗#947
Conversation
|
@bricss thank you for trying to implement this. Please remove everything not related to implementing this feature, there seems to be a lot of unrelated changes. |
|
Unrelated changes include fix 🪛 for build to work on Windows 🪟 machines, removal of redundant escapes inside regexp literals, and change of regexp that matches quoted strings to increase its performance twofold. I can remove and forget about em, or create separate PR in case if that one will land 🛬 |
|
Please remove anything unrelated. You can open separate PRs for those other things. |
|
Removed unrelated changes except for type annotations 📝 |
|
Please remove all unrelated type annotations as well. |
|
@bricss sorry for the delay in reviewing this. Can you please rebase over |
052c8de to
98d75e5
Compare
| } | ||
|
|
||
| function normalizeObject(object) { | ||
| return object === null ? null : Object(object); |
There was a problem hiding this comment.
What is the purpose of this?
There was a problem hiding this comment.
This function ensures a value is safe 🦺 to use as an object, with one special case for null.
There was a problem hiding this comment.
This could open us up to edge cases and break existing templates. Since it's not necessary for this PR to function, please remove it and just use the objects directly like it was doing before.
There was a problem hiding this comment.
It seems 💡 to me that the correct way to handle this would be to default to:
function normalizeObject(object) {
return Object(object);
}Otherwise raw object regresses on three fronts at once: primitive access, null, and undefined. Coz the whole point of the helper is to guarantee the value handed to in/Object.keys/[key] is always a genuine object. 🤔
There was a problem hiding this comment.
Please just focus on what is necessary for this PR and do what I asked. If you would like to submit a separate PR to address any issues with how objects are handled, please do so.
There was a problem hiding this comment.
The function has been removed 🪚, but unfortunately I can't completely get rid of object normalization coz then plenty of tests will start to fail.
This PR is an attempt to bring support for optional chaining
(?.)into the engine.