Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Typscript Error on Class Constructor - No index signature with a parameter of type 'string' was found on type 'BarberModel'

$
0
0

I have a class constructor and I want populate it with an object that I receive in constructor. But I don't know how to solve this TS error on line this[key] = object[key]

Typescript Errorenter image description here

Code

constructor(object: any) {        if (object) {          for (const key in object) {            if (object.hasOwnProperty(key)) {              this[key] = object[key];            }          }        }      }

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>