Commit 9506cdf
committed
fix(compiler-cli): infer type of event target for void elements (angular#62648)
Currently we infer the target of DOM events to be `EventTarget | null` which is consistent with the built-in types for `addEventListener`. This is due to the fact that users can dispatch custom events, or the event might've bubbled. However, this typing is also inconvenient for some other common use cases like `<input (input)="query($event.target.value)">`, because we don't have the ability to type cast in a template.
These changes aim to make some of the cases simpler by inferring the type of `$event.target` if the event is bound on a void element which guarantees that it couldn't have bubbled.
PR Close angular#626481 parent 2ab638d commit 9506cdf
File tree
3 files changed
+101
-2
lines changed- packages/compiler-cli
- src/ngtsc/typecheck
- src
- test
- test/ngtsc
3 files changed
+101
-2
lines changedLines changed: 48 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1642 | 1642 | | |
1643 | 1643 | | |
1644 | 1644 | | |
1645 | | - | |
1646 | 1645 | | |
| 1646 | + | |
| 1647 | + | |
1647 | 1648 | | |
1648 | 1649 | | |
1649 | 1650 | | |
| |||
1652 | 1653 | | |
1653 | 1654 | | |
1654 | 1655 | | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
1655 | 1690 | | |
1656 | 1691 | | |
1657 | 1692 | | |
1658 | 1693 | | |
1659 | 1694 | | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
1660 | 1702 | | |
1661 | 1703 | | |
1662 | 1704 | | |
| |||
3476 | 3518 | | |
3477 | 3519 | | |
3478 | 3520 | | |
| 3521 | + | |
3479 | 3522 | | |
3480 | 3523 | | |
3481 | 3524 | | |
3482 | 3525 | | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
3483 | 3530 | | |
3484 | 3531 | | |
3485 | 3532 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
371 | 377 | | |
372 | 378 | | |
373 | 379 | | |
374 | | - | |
| 380 | + | |
375 | 381 | | |
376 | 382 | | |
377 | 383 | | |
| |||
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8492 | 8492 | | |
8493 | 8493 | | |
8494 | 8494 | | |
| 8495 | + | |
| 8496 | + | |
| 8497 | + | |
| 8498 | + | |
| 8499 | + | |
| 8500 | + | |
| 8501 | + | |
| 8502 | + | |
| 8503 | + | |
| 8504 | + | |
| 8505 | + | |
| 8506 | + | |
| 8507 | + | |
| 8508 | + | |
| 8509 | + | |
| 8510 | + | |
| 8511 | + | |
| 8512 | + | |
| 8513 | + | |
| 8514 | + | |
| 8515 | + | |
| 8516 | + | |
| 8517 | + | |
| 8518 | + | |
| 8519 | + | |
| 8520 | + | |
| 8521 | + | |
| 8522 | + | |
| 8523 | + | |
| 8524 | + | |
| 8525 | + | |
| 8526 | + | |
| 8527 | + | |
| 8528 | + | |
| 8529 | + | |
| 8530 | + | |
| 8531 | + | |
| 8532 | + | |
| 8533 | + | |
| 8534 | + | |
| 8535 | + | |
| 8536 | + | |
| 8537 | + | |
| 8538 | + | |
| 8539 | + | |
| 8540 | + | |
8495 | 8541 | | |
8496 | 8542 | | |
0 commit comments