-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerfreq1: lowhotlist: error messagesstate: confirmedstate: has PRtype: bug/fix
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/compilerIs this a regression?
NoDescription
Currently $event
and $any
are treated as property read of ImplicitReceiver
(this
), and expanded to this.$event
/this.$any
by parser. Which means that user could manually write this.$event
to access to $event
object.
So the the following code are totally valid:
<button (click)="onClick(this.$any(this.$event))">Click Me!</button>
It's a really terrible pattern in template usage, gives the impression that these magical properties being assigned to component instance.
Instead, the parser should treat them as lexical identifier in the first place and forbid this.
usage. It also applies to template reference.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-mgjryy?file=src%2Fapp%2Fapp.component.html
🔥 Exception or Error
N/A
🌍 Your Environment
Angular Version:
7.2.5 now but doesn't matter
Anything else relevant?
This should be easy to implement once #30277 landed.
alxhub
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerfreq1: lowhotlist: error messagesstate: confirmedstate: has PRtype: bug/fix