title: How to initialize a variable in a class to its generic value using Typescript
body: <p>I am building a component to hold information about fields for use in a form.  I need to hold various data objects to create generic routines for working with the data.</p>
  
  <pre><code>export class DataField&lt;T&gt; {
      /**
       * Data field name IE: database column name, JSON field, etc.
       */
      private Name_: string;
      private Size_: number;
      /**
       * The data type for this field. IE: String, Boolean, etc. Note that this is set internally, and is not set by a passed reference
       */
      private Type_: T;
      // private Type_: { new(): T ;}   &lt;- this has not worked either
  
      /**
       * Class constructor
       * @param FieldName string Name of the Field
       * @param FieldSize number Field Size
       */
      constructor(FieldName:string, FieldSize:number) {
          this.Name_ = FieldName;
          this.Size_ = FieldSize;
      }
  
      /**
       * Get the data type for the value
       * @returns string The TypeOf the value
       */
      get Type(): string {
          return (typeof this.Type_).toString();
      }
  }
  </code></pre>
  
  <p>The problem that I have is that the field Type_ is not initialized to anything, so it is always set as undefined.  When I create the DataField with the generic, it might look like:</p>
  
  <pre><code>new DataField&lt;string&gt;('FullName', 32);
  </code></pre>
  
  <p>The generic type T is now <code>string</code>, but I want to be able to get the Type_ variable set so the call to <code>get Type()</code> will return a string.</p>