title: Is there a way in TypeScript to extend multiple classes and upon instantiation display all those default values?
body: <p>The wording of my question might be poor, but I'm trying to extend multiple classes in TypeScript and whenever I instantiate the object, I don't want any of the properties to be undefined.  So in my various classes, I assign the variables values, but when I log it, they don't show up.  In reading the Typescript docs, they mention using a mixin and that works if I want to access a variable, but all the variables are undefined, even though I defined them.</p>
  <p>What I'm looking for is this...</p>
  <pre><code>const c = new C();
  console.log(c)
  </code></pre>
  <p>Whenever I console log this is what I want to see</p>
  <pre><code>&quot;propC1&quot;: &quot;C1&quot;
  &quot;propA1&quot;: &quot;A1&quot;
  &quot;propA2&quot;: &quot;A2&quot;
  &quot;propB1&quot;: &quot;B1&quot;
  &quot;propB2&quot;: &quot;B2&quot;
  &quot;myNumber&quot;: 1000
  </code></pre>
  <p>Instead I only see</p>
  <pre><code> &quot;propC1&quot;: &quot;C1&quot;
  </code></pre>
  <p>Here is the code</p>
  <pre><code>function applyMixins(derivedCtor: any, baseCtors: any[]) {
      baseCtors.forEach(baseCtor =&gt; {
          Object.getOwnPropertyNames(baseCtor.prototype).forEach(name =&gt; {
              if (name !== 'constructor') {
                  derivedCtor.prototype[name] = baseCtor.prototype[name];
              }
          });
      }); 
  }
  
  class Z {
    constructor(public myNumber = 1000){}
  }
  
  class A extends Z{
    constructor(...){
      super();
    }
  }
  
  class B{
    constructor(...){}
  }
  
  interface C extends A, B {}
  
  class C implements A, B{
    public propC1 = &quot;C1&quot;;
  }
  
  applyMixins (C, [A, B]);
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAQwA6oDYE8CyMAeMYAzgBQAmApgE4wBul5AwlHNQFwphYA0iARsmKUWbYp2TcA2gF0AlIgDeAKERqBQka2rEAdMDYBRZBAAWpQcNHVEAXgB8S1epcB5fgCtK0XQHNKUK4A7mAACtRwqDRQWAByyAC2lGSWWmy6qBGsMVFy%20kYm5mCJlHaOKi6VLjDAiKTFSYgAhLa2iADkEAjEUNQg0GztChVVo2pUtAzM2hlZcDmUUg2UMnYaVjOZ8-NYUUslMgDczmNqAL4nlWdyxy7Xh4jKF8oQGELEiABaTmpdJL39bSkVAgfgYGAQRAJOIgBL8GhrACMAAZUXJFBdnq93ogAIKISj4KCUMDkD6fEZ-Hp9AbUUiXEFgiGILaoXGItYAInZnJ4DNB4MhrNxACYuaLec45M4RmpiCAonSbs5McoXm9iB8AEKU7oA2n0lyMwUsiKoLUctqci2So0C5msrViq1O22IaVqDFPNVEYnUYAmUpMAlEklkvF8LU-R5YjUfYMwBKYShJMBQD64yMjY0Os1MS2ITn5znHZ5oTC4AhED6kJh8KSZxBa%20THNVUqCISFtMCUIKIJikG5AA" rel="nofollow noreferrer">Typescript Playground here</a></p>