I was angry with TypeScript today as well.
something.tsx
const months = document.getElementById('datetime_2i')
months ? (months.options[1].selected = true) : null
error
> Property 'options' does not exist on type 'HTMLElement'.
I'm thinking of HTMLSelectElement.
It seems that you should write if you intend. It takes time soberly.
something.tsx
const months = document.getElementById('datetime_2i') as HTMLSelectElement
months ? (months.options[1].selected = true) : null
TypeScript amateur gets angry. Make a note every time the error is resolved.
Property 'selectedOptions','selectedIndex','options' does not exist on type 'HTMLElement' https://sharepoint.stackexchange.com/questions/283252/property-selectedoptions-selectedindex-options-does-not-exist-on-type-htm
Recommended Posts