title: How to get the type of T inside generic method in Typescript?
body: <p>I have a generic method in a class.,</p>
  
  <pre><code>export class BaseService {
      public getAll&lt;T&gt;(): Observable&lt;T&gt; {
          // get type of T
  
          // const type = typeof(T); // Tried this but getting compilation exceptions 
  
          return this.http.get&lt;T&gt;(this.actionUrl + 'getAll');
      }
  }
  </code></pre>
  
  <p>I'll be calling the method like below, from few other typescript classes.</p>
  
  <pre><code>this.service.getAll&lt;SubscriberData&gt;().subscribe(response =&gt; {
        // Response
      }, error =&gt; {
        console.log(error);
      }, () =&gt; {
        // do something commonly
      });
  </code></pre>
  
  <p>When i tried this getting the following exception</p>
  
  <pre><code>const type = typeof(T); 
  </code></pre>
  
  <blockquote>
    <p>'T' only refers to a type, but is being used as a value here.</p>
  </blockquote>
  
  <p><strong>Edit:</strong></p>
  
  <p>I'm trying to get the type of a class which is calling the generic method. For Ex: <code>getAll&lt;SubscriberData&gt;</code> i want to get the type <code>SubscriberData</code> inside that method.</p>
  
  <p>How can i do this?</p>