title: How to properly wrap constructors with decorators in TypeScript
body: <p>The process of wrapping a class with a decorator causes superclasses to be unable to access that classes' properties. Why?</p>
  
  <p>I have some code that:</p>
  
  <ol>
  <li>Creates a decorator which replaces the constructor of a class with a new constructor that should do the exact same thing.</li>
  <li>Creates a base class with a property.</li>
  <li>Wraps the base class with the wrapping decorator.</li>
  <li>Creates a class that extends the base class.</li>
  <li>Tries to access the property on the extended class. This is the part that fails.</li>
  </ol>
  
  <p>Here is the code:</p>
  
  <pre><code>function wrap(target: any) {
    // the new constructor
    var f: any = function (...args) {
        return new target();
    }
  
    f.prototype = target.prototype;
    return f;
  }
  
  @wrap
  class Base {
      prop: number = 5;
  }
  
  class Extended extends Base {
      constructor() {
          super()
      }
  }
  
  var a = new Extended()
  console.log(new Extended().prop) // I'm expecting 5 here, but I get undefined.
  </code></pre>
  
  <p>I'm sure this is some nuance of either prototypes in general or the specific way that TypeScript handles them that I do not grasp.</p>