I am using TypeScript Version 2 for an Angular 2 component code.
I am getting error "Property \'value\' does not exist on type \'EventTarget\'" for below co
Since I reached two questions searching for my problem in a slightly different way, I am replicating my answer in case you end up here.
In the called function, you can define your type with:
emitWordCount(event: { target: HTMLInputElement }) {
this.countUpdate.emit(event.target.value);
}
This assumes you are only interested in the target
property, which is the most common case. If you need to access the other properties of event
, a more comprehensive solution involves using the &
type intersection operator:
event: Event & { target: HTMLInputElement }
You can also go more specific and instead of using HTMLInputElement
you can use e.g. HTMLTextAreaElement
for textareas.