Avoid adding colon for track in 3rd expression of for blocks (#15887)

This commit is contained in:
SUZUKI Sosuke authored and GitHub committed 2024-01-08 15:20:06 +09:00
1 parent 5c6450db9c
commit 06c7e52da6
4 files changed
+32 -1

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
#### Avoid adding colon for `track` in 3rd expression of `for` blocks (#15887 by @sosukesuzuki)
<!-- prettier-ignore -->
```html
<!-- Input -->
@for (item of items; let i = $index; track block) {}
<!-- Prettier stable -->
@for (item of items; let i = $index; track: block) {}
<!-- Prettier main -->
@for (item of items; let i = $index; track block) {}
```
+1 -1
View File
@@ -66,7 +66,7 @@ function printAngular(path, options, print) {
(node.key.name === "then" ||
node.key.name === "else" ||
node.key.name === "as")) ||
(index === 2 &&
((index === 2 || index === 3) &&
((node.key.name === "else" &&
parent.body[index - 1].type === "NGMicrosyntaxKeyedExpression" &&
parent.body[index - 1].key.name === "then") ||
@@ -285,6 +285,12 @@ item of
<div *ngFor="item of items; track item"></div>
</div>
<div>
@for (item of items; let i = $index; track block) {}
<div *ngFor="item of items; let i = $index; track block"></div>
</div>
=====================================output=====================================
<ul>
@for (let item of items; index as i; trackBy: trackByFn) {
@@ -332,6 +338,12 @@ item of
<div *ngFor="item of items; track item"></div>
</div>
<div>
@for (item of items; let i = $index; track block) {}
<div *ngFor="item of items; let i = $index; track block"></div>
</div>
================================================================================
`;
@@ -52,3 +52,9 @@ item of
<div *ngFor="item of items; track item"></div>
</div>
<div>
@for (item of items; let i = $index; track block) {}
<div *ngFor="item of items; let i = $index; track block"></div>
</div>