D
D
damn2020-06-10 20:57:09
typescript
damn, 2020-06-10 20:57:09

How to fix error TS2339: Property 'myFormName' does not exist on type 'HTMLCollectionOf'?

In line

const form: HTMLFormElement = document.forms.myFormName;

compile time error -
TS2339: Property 'myFormName' does not exist on type 'HTMLCollectionOf '.

How to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2020-06-10
@lovebarcafc

const form = document.forms.namedItem('myFormName');

G
GF, 2020-06-10
@fomenkogregory

const form: HTMLFormElement = (document.forms as HTMLCollectionOf<HTMLFormElement>).myFormName

try like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question