馃悶 bug report
Affected Package
The issue is caused by package @angular/compiler
Is this a regression?
No
Description
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
馃實 Your Environment
Angular Version:
7.2.5 now but doesn't matter
Anything else relevant?
This should be easy to implement once #30277 landed.
馃悶 bug report
Affected Package
The issue is caused by package @angular/compilerIs this a regression?
NoDescription
Currently
$eventand$anyare treated as property read ofImplicitReceiver(this), and expanded tothis.$event/this.$anyby parser. Which means that user could manually writethis.$eventto access to$eventobject.So the the following code are totally valid:
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
馃實 Your Environment
Angular Version:
Anything else relevant?
This should be easy to implement once #30277 landed.