title: TypeScript: Generic function return null
body: <p>I am having the next function in typescript:</p>
  
  <p>In c# you have something like <strong>default(T)</strong> but in typescript I dont know.</p>
  
  <pre><code>public Base {
  ...
  }
  
  
  public Get&lt;T extends Base&gt;(cultura: string): T[] 
  {
  
      let res = null;
  
      try
      {
  
      }
      catch (ex)
      {
          throw ex;
      }
  
      return res;
  }
  </code></pre>
  
  <p>I want to return a null but I get an error. If I assign it in a variable the <em>null</em> and return the variable happens the same error.</p>
  
  <p>Message is: The 'null' type can not be assigned to the type T[].</p>
  
  <p>The error is:</p>
  
  <p><a href="https://i.stack.imgur.com/L8PgN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/L8PgN.png" alt="enter image description here"></a></p>
  
  <p>How can I do it in TypeScript?</p>