New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe navigation operator (?.) #549
Comments
Even aurelia v1 has this feature implicitly built-in in expression. We don鈥檛 need the syntax, because our expression always does the check to avoid runtime exception. |
This syntax is coming to the ES spec and our intent with the expression syntax is to stay as close to native as possible. With this syntax, there is a clean and easy way to get this kind of safety whilst also being able to opt out of it (by not using the syntax). So while we don't need the syntax, I still think we should have it, because it improves consistency. |
It will be a not obvious breaking change for Aurelia 2 from v1. So some decision has to be made. |
Doesn't sound breaking to me. If I understand Fred, the only difference is that the Expression parser will now understand |
I think you should consider Current Stage: Stage 3 Milestone: Typescript 3.7 |
@davismj No, my idea is to switch the behavior to null-coalescing operator and then to have the vCurrent compat package turn on a flag where the old behavior is retained, but with the new behavior it would be a breaking change. And it is a good one imo, because:
@HamedFathi Yep, agree, will get that in too |
Please, don't introduce the |
@rmja while I personally appreciate the flexible syntax, I've squashed LOTS of bugs that have to do with properties being uninitialized. While some would prefer the flexibility and say the responsibility falls on the developer, others prefer a more explicit syntax, which would warn them when they've introduced a potential bug into the system. As long as the more flexible syntax is easily toggled, I think the introduction will be a welcome change. |
@rmja As I explained in the previous comment, it would be a toggle, a strictness option. I would probably use If we forced this on everyone, this in itself would be a massive breaking change for no good reason. Of course we'll avoid anything like that. So, no one would be forced to use the syntax so at the very least migration from v1 stays as painless as possible |
Rather than a feature flag or compatibility package for the operator itself why not flag the strictness of template evaluations and the behavior of null in general? Perhaps something along the lines of "template strict evaluation" and "template render null as default"? Default: Strict: the first would throw |
Agree @CuddleBunny |
Aurelia taught TypeScript everything it knows about optional chaining. |
Closing this as supported for optional syntax and bullish coalescing has been merged in thanks to the work of @fkleuver |
馃檵 Feature Request
Recently, Optional Chaining for JavaScript went to
stage 3
. Seems we will achieve this feature in JS and TS soon.Milestone: Typescript 3.7
Suggestion: "safe navigation operator", i.e. x?.y
Angular 2+ supports this feature long time ago as The safe navigation operator ( ? ) and null property paths
Is it possible to support this operator in Aurelia vNext template engine too?
馃 Expected Behavior
Skip rendering if the
item
isnull
orundefined
.馃槸 Current Behavior
We don't have this operator now.
馃捇 Examples
The text was updated successfully, but these errors were encountered: