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

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]

Code

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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source