Property 'value' does not exist on type 'EventTarget & Element'.

// If you have to use event.target itself, you would have to cast the object:

const { name } = event.target as HTMLButtonElement;

0
0

                                    To prevent this error you can write:

var plotDiv: any = document.getElementById('myDiv');
plotDiv.on('plotly_relayout', ...
document.getElementById('myDiv') return HTMLElement. This type doesn't contain method
on because this method is added within plotly-latest.min.js. So in order to silence
the typescript warning you can explicity say compile not to check types for plotDiv

Another way is create type definition like:

interface PlotHTMLElement extends HTMLElement  {
  on(eventName: string, handler: Function): void;
}

var plotDiv  = <PlotHTMLElement>document.getElementById('myDiv')
plotDiv.on('plotly_relayout', function() {

});

0
0
4.5
4
C Foley 100 points

                                    (e.target as HTMLButtonElement).value

4.5 (4 Votes)
0
4.25
4

                                    @Zyon Lyod has already provided the code and some explanation but i will add
more details:
The problem is that not all html events have the value property. And thus not all
event.target have that property since event.target is a generic html element
so you need to cast to the html element that you are using
You are welcome,

4.25 (4 Votes)
0
4.5
4
Exjoburger 70 points

                                    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.

4.5 (4 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
Property '' does not exist on type 'Object'. property 'value' does not exist on type 'eventtarget' angular html Property 'value' does not exist on type 'ElementRef ' Property 'target' does not exist on type 'ElementRef<any>' property 'find' does not exist on type 'htmlelement' property value doeds not exist on type event target Property 'select' does not exist on type 'HTMLElement'. property 'find' does not exist on type 'object' Property 'find' does not exist on type '{}' 'value' does not exist on type 'Element'. Property does not exist on type '() => Element' property 'value' does not exist on type 'element' typescript property value does not exist on type event Property 'text' does not exist on type 'HTMLElement'. property does not exist on type any property 'id' does not exist on type 'eventtarget'.ts Property 'val' does not exist on type 'HTMLElement'.ts(2339) Property 'value' does not exist on type 'Element error in javascript Property 'value' does not exist on type 'Element in js property value' does not exist on type 'eventtarget angular template property 'value' does not exist on type 'eventtarget'. angular html Property '' does not exist on type 'object' Property 'get' does not exist on type jsuery Property 'get' does not exist on type Property 'tags' does not exist on type '{}'.ts(2339) typescript Property 'value' does not exist on type 'Element'. "Property 'name' does not exist on type 'Element'" Property "'name'" does not exist on type 'Element'.ts(2339) Property 'name' does not exist on type 'Element'.ts(2339) property "'element'" does not exist on type 'htmlelement'.ts(2339) Property 'elements' does not exist on type 'HTMLElement'.ts(2339) TS2339: Property 'value' does not exist on type 'EventTarget'. vue 3 react Property 'files' does not exist on type 'EventTarget'.ts react Property 'files' does not exist on type 'EventTarget'.ts(2339) property 'value' does not exist on type 'eventtarget' angular 12 Property '' does not exist on type typescript Property 'selectOption' does not exist on type 'JQuery<HTMLElement>'.ts(2339) any Property 'name' does not exist on type 'EventTarget | null'.ts(2339) Property 'item' does not exist on type 'Object'. Property 'value' does not exist on type 'HTMLElement'.ts when set the value of elmement Property 'target' does not exist on type 'EventTarget property 'value' does not exist on type 'Element Property 'value' does not exist on type 'EventTarget & Element'.ts(2339) Property 'use' does not exist on type 'typeof Property 'getElementById' does not exist on type 'SVGElement' Property 'value' does not exist on type 'EventTarget' select Property '' does not exist on type angular property 'value' does not exist on type 'elementref Property 'target' does not exist on type 'EventListener'. Property 'files' does not exist on type 'EventTarget'.ts react Property 'value' does not exist on type 'EventTarget'. on input TS2339: Property 'value' does not exist on type 'EventTarget' react Property 'current' does not exist on type 'Object' Property 'exists' does not exist on type Property 'width' does not exist on type 'HTMLElement Property 'value' does not exist on type 'EventTarget'. html Property 'attr' does not exist on type 'HTMLInputElement' property id does not exist on eventtarget Property 'detail' does not exist on type 'Event property 'contains' does not exist on type 'any[]'. typescript Property 'value' does not exist on type 'EventTarget' angular Property 'value' does not exist on type 'Element' Property 'value' does not exist on type 'number'.ts( Property '' does not exist on type '' angular 9 Property '' does not exist on type '' angular Property 'value' does not exist on type '(EventTarget & Element) | (EventTarget & HTMLInputElement)'. any Property 'value' does not exist on type 'EventTarget' Property 'id' does not exist on type '{}'. TS2339 Property this. does not exist on type Property 'value' does not exist on type 'HTMLElement'.Vetur(2339) property 'value' does not exist on type 'eventtarget' angular 11 Property 'p' does not exist on type 'object' Property 'time' does not exist on type '() => Element'.ts(2339) Property 'class' does not exist on type 'HTMLElement' Property 'target' does not exist on type 'HTMLElement'.ts(2339) Property 'input' does not exist on type 'HTMLElement'. TS2339 property does not exist on type jquery htmlelement Property 'addEventListener' does not exist on type 'ElementRef<any> Property 'id' does not exist on type 'object[]'.ts(2339) Property 'install' does not exist on type '{}'. property value does not existe on type element property 'files' does not exist on type 'eventtarget' react Property '' does not exist on type 'string | '. property does not exist on type element Property 'options' does not exist on type 'EventTarget & HTMLInputElement'. Property 'tagName' does not exist on type 'EventTarget'. Property 'valuechanges' does not exist on type 'string' Property '' does not exist on type '{}'.ts(2339) property 'detail' does not exist on type 'event' property value does not exist on type eventtarget angular property value does not exist on type text typescript error property does not exist on type Property 'target' does not exist on type FormEventHandler<Element> property id does not exist on type eventtarget property 'value' does not exist on type 'eventtarget'. angular9 react typescript property 'value' does not exist on type 'eventtarget' typescript Property 'value' does not exist on type 'EventTarget Property 'className' does not exist on type 'EventTarget'. Property 'id' does not exist on type 'EventTarget | null'. REACT Property 'id' does not exist on type 'EventTarget | null'. angular Property 'valueChanges' does not exist on type Property 'Error' does not exist on type 'Object'. Property 'value' does not exist on type 'Element'. jest property 'and' does not exist on type '() => any Property 'value' does not exist on type 'HTMLElement' "Property 'target' does not exist on type 'HTMLElement'" Property 'target' does not exist on type 'HTMLElement'. react ts does not exist on type 'EventTarget'. Property 'result' does not exist on type 'EventTarget'.ts(2339) Property 'nodeName' does not exist on type 'EventTarget'.ts(2339) Property 'value' does not exist on type 'HTMLElement'.ts(2339 Property '_value' does not exist on type 'ElementRef Property '_value' does not exist on type 'ElementRef<any>'.ts(2339) TS2339: Property 'value' does not exist on type 'Element'. Property 'define' does not exist on type 'typeof AceAjax'. Property 'target' does not exist on type '() => void' typescript Property 'value' does not exist on type 'HTMLElement' how to ignore Property 'value' does not exist on type 'EventTarget' Property 'which' does not exist on type 'Event'. Property 'id' does not exist on type 'EventTarget' react Property 'id' does not exist on type 'EventTarget' Property 'value' does not exist on type 'EventTarget & HTMLElement'.react Property 'value' does not exist on type 'EventTarget & HTMLElement' grepper Property 'value' does not exist on type 'EventTarget' inside a function grepper Property 'value' does not exist on type 'EventTarget' grepper Property 'value' does not exist on error Property 'className' does not exist on type 'EventTarget'. react click event Property 'height' does not exist on type 'HTMLElement'. Property 'addEventListener' does not exist on type 'Element'.ts(2339) property '' does not exist on type ''. angular property '' does not exist on type 't'. angular Property 'id' does not exist on type '{} Property 'id' does not exist on type 'EventTarget the property 'value' does not exist on value of type 'htmlelement' Property 'complete' does not exist on type 'EventTarget' Property 'complete' does not exist on type 'EventTarget'. how to handle " property ' ' does not exist on type ' ' in angular Property 'nodeName' does not exist on type 'EventTarget'. Property 'value' does not exist on type 'HTMLElement'. typescript js property 'value' does not exist on type 'htmlelement' eval Property 'value' does not exist on type 'HTMLElement'. any Property 'value' does not exist on type 'Element'. Property 'id' does not exist on type 'object'.Vetur(2339) Property 'selectedOptions' does not exist on type '(EventTarget & HTMLInputElement) Property 'id' does not exist on type '{}'.ts(2339) property 'value' does not exist on type 'eventtarget' primeng Error TS2339: Property 'id' does not exist on type 'EventTarget' Property 'elements' does not exist on type 'EventTarget' Property 'getAttribute' does not exist on type 'EventTarget'. any Property 'value' does not exist on type 'HTMLElement'. error TS2339: Property 'value' does not exist on type 'HTMLElement'. TS2339: Property 'id' does not exist on type 'EventTarget'. Property 'elements' does not exist on type 'EventTarget'. property select does not exist on type htmlelement Property 'value' does not exist on type 'EventTarget'. 2 <input type="text" (keyup)=getVal($event.target.value)> ~~~~~ Property 'status' does not exist on type 'Document<any, {}>' Property ' ' does not exist on type 'Object' Property 'get' does not exist on type '{}' angular 8 Property does not exist on type 'HTMLElement'. Property 'target' does not exist on type 'HTMLLIElement' any Property 'getElementById' does not exist on type 'HTMLGdsSwimlaneElement' Property 'oncopy' does not exist on type 'ElementRef<HTMLElement>'.ts(2339) Property 'select' does not exist on type 'EventTarget' Property 'target' does not exist on type 'HTMLElement' Property 'val' does not exist on type 'object' Property 'state' does not exist on type 'HTMLScriptElement'. property 'this' does not exist on type Property 'className' does not exist on type 'EventTarget'.ts(2339) error TS2339: Property 'value' does not exist on type 'EventTarget'. property html does not exist on type htmlelement angular property html does not exist on type htmlelement angular 6 Angular Property 'value' does not exist on type 'EventTarget' property does not exist on type 'Document any' Property 'value' does not exist on type 'string'.ts(2339) Property 'options' does not exist on type 'HTMLElement'. Property 'document' does not exist on type 'IDocumentModel[]'.ts(2339) angular Property 'value' does not exist on type 'HTMLElement' getattribute' does not exist on type 'eventtarget' react Property 'current' does not exist on type '(: any) => () => void' Property 'text' does not exist on type 'object'. property 'value' html élément does not exist on type 'htmlelement' property '' does not exist on type ''.ts(2339) Property 'name' does not exist on type 'EventTarget'.ts(2339) "react" Property 'name' does not exist on type 'EventTarget'.ts(2339) react Property 'name' does not exist on type 'EventTarget'.ts(2339) Property '' does not exist on type 'typeof property 'show' does not exist on type 'htmlelement' Property 'id' does not exist on type '{}' property does not exist on type 'Document'. property 'setattribute' does not exist on type 'eventtarget' Property 'on' does not exist on type 'Options' property 'getelementbyid' does not exist on type 'htmldivelement' Property 'target' does not exist on type 'HTMLDivElement Property 'value' does not exist on type 'Element' -htmlelement Property 'tagName' does not exist on type 'EventTarget'.ts(2339) Property 'id' does not exist on type '{}'. ts options' does not exist on type 'htmlelement' react Property 'value' does not exist on type 'EventTarget' property 'value' does not exist on type 'eventtarget angular 11 property 'value' does not exist on type 'eventtarget' angular Property 'value' does not exist on type 'EventTarget'. 7 ="username = $event.target.value"> property 'value' does not exist on type 'eventtarget' react typescript Property 'onreadystatechange' does not exist on type 'HTMLScriptElement'.ts(2339) property 'value' does not exist on type 'htmlelement' angular property 'value' does not exist on type 'htmlelement' react propriété value does not exist on type 'html element' angular propriété value does not exist on type 'htmlelement' angular propiete value doesn exist on type 'htmlelement' angular Property 'name' does not exist on type 'Element'. Property 'select' does not exist on type 'HTMLElement' Property 'value' does not exist on type 'Element'. Property 'type' does not exist on type 'Element'. property 'type' does not exist on type 'object' Property 'onerror' does not exist on type 'EventTarget'. react Property 'value' does not exist on type 'EventTarget'. Property 'value' does not exist on type 'EventTarget'. angular 11 Property 'waitUntil' does not exist on type 'Event'. Property 'waitUntil' does not exist on type 'Event' Property 'ASN1HEX' does not exist on type 'typeof jsrsasign' roperty 'elements' does not exist on type 'EventTarget'.ts(2339) Property 'value' does not exist on type Did you mean 'values'? Property 'value' does not exist on type object property does not exist on type object Property 'onerror' does not exist on type 'EventTarget' property element value is not exist on type hml element ' property does not exist on type 'element Property 'error' does not exist on type '{}' Property 'key' does not exist on type 'EventTarget' property 'value' does not exist on type 'eventtarget in html Property 'id' does not exist on type 'EventTarget'. Property 'value' does not exist on type 'EventTarget | null typescript Property 'value' does not exist on type 'HTMLElement property 'value' does not exist on type 'eventtarget & element' angular Property 'value' does not exist on type ' Property 'value' does not exist on type 'EventTarget & Element'. typescript value does not exist on eventtarget Property 'value' does not exist on type 'EventTarget'. primeng Property 'of' does not exist on type 'typeof Property 'value' does not exist on type 'EventTarget' react Property 'value' does not exist on type 'string' 'value' does not exist on type 'EventTarget' onchange Property 'srcObject' does not exist on type 'HTMLElement'.ts(2339) Property 'hasError' does not exist on type 'HTMLInputElement' angular Property 'nodeName' does not exist on type 'EventTarget' Property 'value' does not exist on type 'EventTarget'. react Property 'value' does not exist on type 'Element'.ts(2339) Property 'id' does not exist on type '{}'. Property 'type' does not exist on type 'Object'. Property 'type' does not exist on type 'EventTarget'.ts(2339) Property 'Item' does not exist on type 'Object'.ts(2339) Property 'target' does not exist on type 'EventTarget' typescript react Property 'value' does not exist on type 'HTMLElement'. Property 'getAttribute' does not exist on type 'EventTarget' Property 'name' does not exist on type 'EventTarget react typescript Property 'name' does not exist on type 'EventTarget react javascript property does not exist on type Property 'find' does not exist on type typescript property does not exist on type htmlelement Property 'html' does not exist on type 'HTMLElement Argument of type 'EventTarget & HTMLInputElement' is not assignable to parameter of type 'SetStateAction<null>'. Type 'EventTarget & HTMLInputElement' is not assignable to type '(prevState: null) => null'. Type 'EventTarget & HTMLInputElement' is not assignable to type '(prevState: null) => null'. location does not exist on type htmlinputelement typescript element doesnot contain type alt property 'value' does not exist on type 'htmlinputelement' angular radio button change Type 'EventTarget' is missing the following properties from type 'HTMLInputElement': accept, align, alt, autocomplete, and 284 more. Property 'href' does not exist on type 'HTMLSpanElement'. htmlelement to angular input Property 'value' does not exist on type 'EventTarget onClick typescript onClick event.target.value Typescript error typescript error in event.target.value Types of property 'target' are incompatible. Property 'value' is missing in type 'EventTarget' but required in type '{ value: any; }'. vue typescript Property 'value' does not exist on type 'HTMLElement' Property 'value' does not exist on type 'EventTarget'. svelte htmlelement input angular react event.target doesnt have value property Property 'value' does not exist on type 'HTMLElement'.ts(2339) react select Property 'value' does not exist on type 'EventTarget' Property 'on' does not exist on type 'HTMLElement'. Property 'on' does not exist on type 'HTMLDivElement'. property 'value' does not exist on type 'htmlelement' typescript does not exist on type 'HTMLElement'. angular Property 'value' does not exist on type 'number' event.target.value Property 'href' does not exist on type property 'value' does not exist on type 'htmlelement'. angular Property 'reset' does not exist on type 'HTMLElement'. js event.target not exists Property 'tagName' does not exist on type 'EventTarget' in react typescript submit does not exist on type eventtarget Property 'value' does not exist on type 'HTMLElement'. jest Property 'value' does not exist on type 'Element'. TS2339 Property 'apply' does not exist on type 'HTMLElement'. apply does not exists in htmelement show does not exist on html element Property show() does not exist on type 'HTMLInputElement' Property 'show' does not exist on type 'HTMLInputElement' Property 'value' does not exist on type 'HTMLElement' jest Property 'value' does not exist on type 'HTMLElement jest tsx Property 'addClass' does not exist on type 'HTMLElement' Property 'value' does not exist on type 'KeyboardEvent'.ts(2339) Property 'value' does not exist on type 'Element' property value does not exist on type element Property does not exist on type error Property 'style' does not exist on type 'Element'.ts(2339) react react keyboard event typescript doesn't have target.value typescript document.getelementbyid value Property 'value' does not exist on type 'EventTarget & Element property checked does not exist on htmlelement Property 'onkeyup' does not exist on type 'Element' Property 'type' does not exist on type 'string' reactnode TS2551: Property "'getElementByCSS'" does not exist on type 'Document'. Did you mean 'getElementById'? TS2551: Property 'getElementByCSS' does not exist on type 'Document'. Did you mean 'getElementById'? property does not exist on type Event Target class [EventType] does not exist. Property 'target' does not exist on type 'Element' angular event.target does not contain value for input e.target.value typescript angular Property 'getElementsByTagName' does not exist on type 'unknown'. Property 'checked' does not exist on type 'EventTarget'. property 'href' does not exist on type 'htmlelement' Property 'call' does not exist on type 'HTMLElement'. any property 'value' does not exist on type 'eventtarget'. angular Property 'className' does not exist on type 'EventTarget' Property 'getElementById' does not exist on type 'DashboardComponent' document.getelementbyid length undefined getAttribute Property 'getAttribute' does not exist on type 'string'.ts(2339) id is not a property of target typescript react event.target.value typescript angular Property does not exist on type 'EventTarget & HTMLInputElement'.ts(2339) Property 'data' does not exist on type 'EventTarget & HTMLInputElement'.ts(2339) property closet doesnot exist on type event target Property 'height' does not exist on type 'HTMLBodyElement'. react target does not exist on eventtarget Property 'addEventListener' does not exist on type 'HTMLCollectionOf<Element>'. typescript value not exist in target KeyboardEvent Type '{ value: string; maxLength: number; }' is not assignable to type 'EventTarget & HTMLInputElement'. js Property 'key' does not exist on type 'FormEvent<HTMLInputElement>' typescript angular Property 'value' does not exist on type 'HTMLElement'. property 'name' does not exist on type 'eventtarget' react selectedOption does not exists angular 8 Property 'target' does not exist on type 'string'.ts(2339) in react Property 'target' does not exist on type 'string'.ts(2339) Property 'target' does not exist on type 'string' Property 'value' does not exist on type 'EventTarget'.ts(2339) 'value' does not exist on type 'EventTarget & Element' Property 'value' does not exist on type 'HTMLInputElement' angular document.getelementbyid() as htmlinputelement (<HTMLInputElement>document.getElementById("name")).value Property 'async' does not exist on type 'HTMLElement' angular REACT TS roperty 'value' does not exist on type 'EventTarget & Element' Property 'text' does not exist on type 'EventTarget' property value does not exist on type eventtarget react Property '' does not exist on type 'HTMLInputElement | null'. property 'value' does not exist on type 'htmlelement' react typescript rror TS2339: Property 'autofocus' does not exist on type 'HTMLElement'. typescript property value does not exist on type htmlelement ts getelementbyid value 'value' does not exist on type 'HTMLElement'.ts(2339) Property 'target' does not exist on type '(event: any) => void' property 'value' does not exist on type 'eventtarget'.ts(2339) react Property 'target' does not exist on type 'HTMLInputElement' property does not exist on type htmlelement angular typescript html element does not have value property value does not exist on type htmlelement typescript property 'submit' does not exist on type 'htmlelement' NPM prod build failing, Property 'value' does not exist on type 'HTMLElement'. Property 'type' does not exist on type 'HTMLElement'.ts(2339) property 'value' does not exist on type 'eventtarget'.tsx(2339) typescript text does not exist in htmlelement Property 'current' does not exist on type 'HTMLDivElement' typescript Property 'current' does not exist on type 'HTMLDivElement'.ts(2339) value does not exist on htmlelement angular Property 'getElementById' does not exist on type 'HTMLElement'. property 'value' does not exist on type 'htmlelement' in angular 8 Property 'value' does not exist on type 'String'. Property 'value' does not exist on type 'HTMLElement' javascript to typescript Property 'value' does not exist on type 'HTMLElement'. value doesnt exist event taget type mouse event erro Property 'href' does not exist on type 'EventTarget' in react Property 'value' does not exist on type 'EventTarget' Property 'value' does not exist on type 'EventTarget' typescript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source