HTMLOptionElement gives error Property 'value' does not exist on type 'Element'.
See original GitHub issueI’m getting this in this case of an HTMLOptionElement value
It should have that value as HTMLOptionsCollection contains HTMLOptionElement elements:
readonly options: HTMLOptionsCollection;
interface HTMLOptionsCollection extends HTMLCollectionOf<HTMLOptionElement> {
length: number;
selectedIndex: number;
add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void;
remove(index: number): void;
}
Using typescript@2.2.1
My workaround was to use an unnecessary cast
let newValue = (target.options[newSelectedIndex] as HTMLOptionElement).value
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
typescript - The property 'value' does not exist on value of type ...
Based on Tomasz Nurkiewiczs answer, the "problem" is that typescript is typesafe. :) So the document.getElementById() returns the type ...
Read more >How To Fix The Property 'value' does not exist on type ...
You would run into the error. The reason for this is that document.getElemetById() has a return value of HTMLElement | null . As...
Read more >Property 'value' does not exist on type 'HTMLElement' in TS
The error "Property 'value' does not exist on type 'HTMLElement'" occurs when we try to access the value property on an element that...
Read more >property value does not exist on type htmlelement - YouTube
Your browser can't play this video. ... property value does not exist on type htmlelement | React NextJS Typescript. 1,912 views1.9K views.
Read more >HTMLOptionElement - Web APIs | MDN
Chrome Edge
HTMLOptionElement Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi...
Option() constructor Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi...
defaultSelected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please fix!
That would be awesome!