property 'name' does not exist on type 'eventtarget' react
// If you have to use event.target itself, you would have to cast the object:
const { name } = event.target as HTMLButtonElement;
property 'name' does not exist on type 'eventtarget' react
// If you have to use event.target itself, you would have to cast the object:
const { name } = event.target as HTMLButtonElement;
Property 'value' does not exist on type 'HTMLElement'.
document.getElementById() returns the type HTMLElement which does not contain a value property.
The subtype HTMLInputElement does however contain the value property.
So a solution is to cast the result of getElementById() to HTMLInputElement like this:
var inputValue = (<HTMLInputElement>document.getElementById(elementId)).value;
<> is the casting operator in typescript.
See TypeScript: casting HTMLElement: https://fireflysemantics.medium.com/casting-htmlelement-to-htmltextareaelement-in-typescript-f047cde4b4c3
The resulting javascript from the line above looks like this:
inputValue = (document.getElementById(elementId)).value;
i.e. containing no type information.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us