title: Typescript filter showing error is not assignable to type
body: <p>This is not working. Shows <strong>error</strong> <code>Type '(Person | null)[]' is not assignable to type 'Person[]'. Type 'Person | null' is not assignable to type 'Person'. Type 'null' is not assignable to type 'Person'.</code></p>
  <pre><code>interface Person {
    name: string;
  }
  
  function filterPersons(persons: Array&lt;Person | null&gt;): Array&lt;Person&gt; {
      return persons.filter(person =&gt; person !== null)
  }
  
  function run() {
      const persons: Array&lt;Person | null&gt; = []
      persons.push(null)
      filterPersons(persons)
  }
  
  run()
  </code></pre>
  <p>But this is working</p>
  <pre><code>interface Person {
    name: string;
  }
  
  function filterPersons(persons: Array&lt;Person | null&gt;): Array&lt;Person&gt; {
      return persons.filter(person =&gt; person !== null) as Array&lt;Person&gt;
  }
  
  function run() {
      const persons: Array&lt;Person | null&gt; = []
      persons.push(null)
      filterPersons(persons)
  }
  
  run()
  </code></pre>
  <p>Any explanation &amp; are there any better solution? Thanks ️</p>