Commit a548c03
fix(compiler-cli): incorrect inferred type of for loop implicit variables (#52732)
Fixes that all implicit variables in `@for` loops were inferred to be numbers, even though most are actually boolean.
Note that I also had to work around a weird TypeScript behavior in `tsDeclareVariable` where usually we declare variables in the following format:
```
var _t1: <type> = null!;
```
This works in most cases, but if the type is a `boolean`, TypeScript infers the variable as `never`, instead of `boolean`. I've worked around it by adding an `as boolean` to the initializer.
Fixes #52730.
PR Close #527321 parent 7a95ccc commit a548c03
File tree
4 files changed
+45
-20
lines changed- packages/compiler-cli
- src/ngtsc/typecheck
- src
- test
- test/ngtsc
4 files changed
+45
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
84 | | - | |
| 94 | + | |
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
| |||
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1572 | 1572 | | |
1573 | 1573 | | |
1574 | 1574 | | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
1575 | 1587 | | |
1576 | 1588 | | |
1577 | 1589 | | |
| |||
1628 | 1640 | | |
1629 | 1641 | | |
1630 | 1642 | | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
1634 | 1649 | | |
1635 | 1650 | | |
1636 | 1651 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1560 | 1560 | | |
1561 | 1561 | | |
1562 | 1562 | | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
1567 | 1567 | | |
1568 | 1568 | | |
1569 | 1569 | | |
| |||
1578 | 1578 | | |
1579 | 1579 | | |
1580 | 1580 | | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
1585 | 1585 | | |
1586 | 1586 | | |
1587 | 1587 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4477 | 4477 | | |
4478 | 4478 | | |
4479 | 4479 | | |
4480 | | - | |
4481 | | - | |
4482 | | - | |
4483 | | - | |
| 4480 | + | |
| 4481 | + | |
| 4482 | + | |
| 4483 | + | |
4484 | 4484 | | |
4485 | 4485 | | |
4486 | 4486 | | |
| |||
4513 | 4513 | | |
4514 | 4514 | | |
4515 | 4515 | | |
4516 | | - | |
4517 | | - | |
4518 | | - | |
4519 | | - | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
4520 | 4520 | | |
4521 | 4521 | | |
4522 | 4522 | | |
| |||
0 commit comments