Typ „HTMLFormControlsCollection” ma właściwość „x” i bez podpisu indeksu ciąg

głosy
0

Ten błąd pojawia się podczas próby destructure się form.elementsobiekt.

// in a class

domRefs: {[key: string]: HTMLFormElement | null} = {
  myForm: null
}

onButtonClick = () => {
  console.debug(this.domRefs.myForm!.elements) // screenshot below
  const {a, b, c} = this.domRefs.myForm!.elements
}

wprowadzić

Nie chcę używać : anytypu, które nie emitują tego błędu.

Utwórz 02/04/2018 o 11:48
źródło użytkownik
W innych językach...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more