title: Typescript Documentation on Class Decorator - function returning "class extends constructor {}"
body: <p>So, I am trying to build understanding about Typescript Decorators and I have been stuck on the example given about Class decorators. The example given shows how to form class decorator through function(){}.</p>
  
  <pre><code>  function classDecorator&lt;T extends {new(...args:any[]):{}}&gt;(constructor:T){
          return class extends constructor {
              newProperty = "new property";
              hello = "override";
          }
      }    
  
      @classDecorator
      class Greeter {
          property = "property";
          hello: string;
          constructor(m: string) {
              this.hello = m;
          }
      }    
  
      console.log(new Greeter("world"));
  </code></pre>
  
  <p>What is the:</p>
  
  <pre><code>return class extends constructor {
      newProperty = "new property";
      hello = "override";
  }
  </code></pre>
  
  <p>How can a function returning a "class" keyword that extends a parameter (called "construct")? I am so confused.</p>
  
  <p>Here is link to original source (just scroll to the middle section on class decorator): <a href="https://www.typescriptlang.org/docs/handbook/decorators.html" rel="nofollow noreferrer">https://www.typescriptlang.org/docs/handbook/decorators.html</a></p>
  
  <p>Appreciate any help!</p>