You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve type checking to include checking model binding #16952
[()] syntax is just a syntax sugar of property binding and event binding. The generalized problem here is that Angular does not provide type checking for event bindings, nothing special to ngModelChange.
You should fill the issue template as a feature request, as it's expected at design level, rather than being a BUG. But this may not be possible for current mechanism, as it's just string comparison for event names, the source of the event is not being tracked during compilation.
In the binding (ngModelChange)="myh.n = $event", myh.n is the property you want to bind to, it's typed properly, but $event is always declared as any.
Theoretically the type of $event may be determined by the generic type of EventEmitter, but there may still be other conditions, like native DOM events and events provided by other EVENT_MANAGER_PLUGINS.
What's more for ngModelChange is that, there is no generic type used in the EventEmitter (in ng_model.ts), the expected declared type it's determined by the NG_VALUE_ACCESSOR, not the NgModel.
So that's why I think this request is way to hard to implement this. Still, this is just my point of view.
changed the title [-]BUG:angular2 model bind make typescript type check missed[/-][+]Improve type checking to include checking model binding[/+]on May 25, 2017
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
In Ivy under strictTemplates, the type of $event is correctly determined by the generic type of EventEmitter of the output in question. However, #13721 will likely need to be resolved as well, to truly solve the problem described in this issue.
Activity
trotyl commentedon May 23, 2017
[()]syntax is just a syntax sugar of property binding and event binding. The generalized problem here is that Angular does not provide type checking for event bindings, nothing special tongModelChange.You should fill the issue template as a feature request, as it's expected at design level, rather than being a BUG. But this may not be possible for current mechanism, as it's just string comparison for event names, the source of the event is not being tracked during compilation.
100cm commentedon May 24, 2017
i think when angular 2 set a property of object , its will not check the type, how to check this ?
trotyl commentedon May 24, 2017
In the binding
(ngModelChange)="myh.n = $event",myh.nis the property you want to bind to, it's typed properly, but$eventis always declared asany.Theoretically the type of
$eventmay be determined by the generic type ofEventEmitter, but there may still be other conditions, like native DOM events and events provided by otherEVENT_MANAGER_PLUGINS.What's more for
ngModelChangeis that, there is no generic type used in theEventEmitter(in ng_model.ts), the expected declared type it's determined by theNG_VALUE_ACCESSOR, not theNgModel.So that's why I think this request is way to hard to implement this. Still, this is just my point of view.
[-]BUG:angular2 model bind make typescript type check missed[/-][+]Improve type checking to include checking model binding[/+]trotyl commentedon Jul 12, 2017
Possibly relates to #17483
angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 25, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
alxhub commentedon Jul 8, 2021
I'm going to close this as resolved, actually.
In Ivy under
strictTemplates, the type of$eventis correctly determined by the generic type ofEventEmitterof the output in question. However, #13721 will likely need to be resolved as well, to truly solve the problem described in this issue.angular-automatic-lock-bot commentedon Aug 8, 2021
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.