Avatar ·

Error Property 'value' does not exist on type EventTarget in TypeScript: how to fix

Hello everyone! I recently started learning Angular and TypeScript, and encountered a very strange error that I can't figure out.\n\nI have a simple component with an input field. When the user enters text, I want to handle the (input) event and get the value from the field. Here is my code:\n\n```typescript\n// my-component.component.ts\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'app-my-component',\n template: `\n \n

You entered: {{ inputValue }}

\n `\n})\nexport class MyComponent {\n inputValue: string = '';\n\n onInput(event: Event): void {\n this.inputValue = event.target.value; // Error here!\n }\n}\n```\n\nTypeScript throws an error: "Property 'value' does not exist on type 'EventTarget'." I understand that th