| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Can we avoid using as? It overlaps with TS casts, that'll be quite confusing for users. |
Sorry, something went wrong.
|
@mprobst as pointed out here #15020 (comment) ES2015 uses it very much in the same way as to the proposed way here, also I do challenge you to find a more fitting word |
Sorry, something went wrong.
|
@Toxicable yeah, the ES6 imports are a point, but that's more of a renaming situation (and also more similar to casts), where this looks to me more like an assignment. We couldn't make *ngIf="var1 = exp” work, could we? That'd also match JS syntax, module introducing a new symbol: if (var1 = exp) { ... use var1 ... }. |
Sorry, something went wrong.
|
@mprobst As explained here #15020 (comment) and in the comment following it explains that let user = foo already has meaning in Angular |
Sorry, something went wrong.
|
I wonder if we could use a different symbol to make the assignment more clear and remove the overlap? let foo := expr? In any case, I'm probably just adding noise here, sorry ;-) |
Sorry, something went wrong.
|
If the as keyword is a problem, why not changing to be ? The intent is very clear and it is not used in Typescript nor JS IMHO: *ngIf="exp as var1” => *ngIf="exp be var1” >> => *ngIf="exp; let var1 = ngIf” |
Sorry, something went wrong.
There was a problem hiding this comment.
so both let i=index and index as i are supported, right? do you think it's a good idea to have multiple ways to do the same thing?
Sorry, something went wrong.
There was a problem hiding this comment.
If we take away let then we break a whole lot of people. So, yes both will be supported.
Sorry, something went wrong.
There was a problem hiding this comment.
I believe we discussed this after this comment was posted and decided that we do want to remove the old way. @mhevery did I understand the conclusion of the conversation correctly?
Sorry, something went wrong.
There was a problem hiding this comment.
I think you should add a console warning that let syntax is deprecated (similar to template element) so it will be easier to remove it in v5
Sorry, something went wrong.
There was a problem hiding this comment.
Old way can't be removed as it would break a lot of people. Think *ngFor="let item of items" What was discussed was to remove *ngIf="exp; let var" However, it turns out that can't be removed either as it would make the else statement weird.
So in summary. Old syntax is supported but the new syntax is preferred. Both will continue to work.
Sorry, something went wrong.
There was a problem hiding this comment.
❤️ 👍 🦄 🌈
Sorry, something went wrong.
There was a problem hiding this comment.
I believe we discussed this after this comment was posted and decided that we do want to remove the old way. @mhevery did I understand the conclusion of the conversation correctly?
Sorry, something went wrong.
There was a problem hiding this comment.
I LOVE that the as can be used for all the local variables. It makes the whole syntax look so much more consistent and cleaner. ❤️
Sorry, something went wrong.
|
With regards to the as conflict with typescript, as others mentioned the conflict already exists with ESM aliasing. Our semantics of as are consistent with that of ESM aliasing and therefor, I don't think that we should be dismissing as on the basis of the typescript conflict. It's also worthwhile keeping in mind that nowhere in Angular templates we use types or have affordances for explicit type position in the syntax, so I that's another argument why the as conflict is a non-issue in my opinion. |
Sorry, something went wrong.
There was a problem hiding this comment.
This doesn't look right to me as it is much more lax in the syntax than you probably intent. You probably meant this to be !this.next.isOperator(chars.$SEMICOLON) && !this.next.isOperator(chars.$COMMA) && because optionalCharacter will advance the token which appears not what you intended.
If you make the above change you need to undelete line 717 an put it after your block.
Sorry, something went wrong.
There was a problem hiding this comment.
fixed
Sorry, something went wrong.
Closes angular#15020 Showing the new and the equivalent old syntax. - `*ngIf="exp as var1”` => `*ngIf="exp; let var1 = ngIf”` - `*ngFor="var item of itemsStream |async as items”` => `*ngFor="var item of itemsStream |async; let items = ngForOf”`
* feat(common): support `as` syntax in template/* bindings Closes angular#15020 Showing the new and the equivalent old syntax. - `*ngIf="exp as var1”` => `*ngIf="exp; let var1 = ngIf”` - `*ngFor="var item of itemsStream |async as items”` => `*ngFor="var item of itemsStream |async; let items = ngForOf”` * feat(common): convert ngIf to use `*ngIf="exp as local“` syntax * feat(common): convert ngForOf to use `*ngFor=“let i of exp as local“` syntax * feat(common): expose NgForOfContext and NgIfContext
|
Why is this limited to ngFor and ngIf? |
Sorry, something went wrong.
|
@realappie it is not limited, if you write your own structural directive it will work there |
Sorry, something went wrong.
* feat(common): support `as` syntax in template/* bindings Closes angular#15020 Showing the new and the equivalent old syntax. - `*ngIf="exp as var1”` => `*ngIf="exp; let var1 = ngIf”` - `*ngFor="var item of itemsStream |async as items”` => `*ngFor="var item of itemsStream |async; let items = ngForOf”` * feat(common): convert ngIf to use `*ngIf="exp as local“` syntax * feat(common): convert ngForOf to use `*ngFor=“let i of exp as local“` syntax * feat(common): expose NgForOfContext and NgIfContext
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #15020
Showing the new and the equivalent old syntax.
=> *ngIf="exp; let var1 = ngIf”
=> *ngFor="var item of itemsStream |async; let items = ngForOf”