title: How to set types of dynamically acquired values in a class
body: <p>I have a class and an interface with the class constructor receiving an instance of an object as the interface so I know all the keys but they are a lot of keys so I am trying not to do them manually and find a way to dynamically do it</p>
  <pre class="lang-js prettyprint-override"><code>import {APIGuild} from &quot;discord-api-types&quot;
  class Main{
  constructor(data: APIGuild){
  for(const key in data){
  this[key as keyof this] = data[key as keyof this]
  }
  }
  }
  </code></pre>
  <p>The problem with this approach is that i am unable to gain the types for the class and using the <code>implements</code> keyword needs all the fields to be initialized which is a lot of work as APIGuild is a extended interface with 30+ fields so initializing them manually is.... bad plus many of the fields have dual possible types so if I assign an empty string to a field and turns out the field had to be null as it was not present may cause future problems</p>