Class<T>: {
    prototype: T;
    new (...args): T;
}

Type Parameters

  • T

Type declaration

    • new (...args): T
    • allows for creation of functions that can create new instances of generic types. Ex:

      function get<T>(cType: Class<T>, ...args: any[]): T {
      return new cType(...args);
      }

      which can then be used like:

      let obj: CustomObj = get(CustomObj, 'foo', 123);
      

      assuming that CustomObj looks like:

      class CustomObj {
      someStr: string;
      someNum: number;
      constructor(inputStr: string, inputNum: number) {
      this.someStr = inputStr;
      this.someNum = inputNum;
      }
      }

      Parameters

      • Rest ...args: any[]

      Returns T

  • Readonly prototype: T

Generated using TypeDoc