title: Why is typescript complaining about filter and how can I resolve this?
body: <p>I need your help with this typescript complaint, I have been struggling with this issue for quite a while now. I am trying to filter an array dynamically, but Typescript is complaining. Here is what it said,</p>
  <pre><code>(property) Array&lt;T&gt;.filter: {
      &lt;S extends {
          x: number;
      }&gt;(predicate: (value: {
          x: number;
      }, index: number, array: {
          x: number;
      }[]) =&gt; value is S, thisArg?: any): S[];
      (predicate: (value: {
          x: number;
      }, index: number, array: {
          x: number;
      }[]) =&gt; unknown, thisArg?: any): {
          x: number;
      }[];
  } | {
      ...;
  } | {
      ...;
  }
  </code></pre>
  <p>Here is what I am trying to do:</p>
  <pre class="lang-typescript prettyprint-override"><code>const shapes ={
    rectangles :[
      {x :1}
    ],
    ellipses :[
      {y :10}
    ],
    polygons :[
      {isFinished :true}
    ]
  }
  
  Object.keys(shapes).forEach(shapeKey =&gt; {
    shapes[shapeKey as keyof typeof shapes].filter(shape =&gt; {
    // 
    // 
    })
  })
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?#code/MYewdgzgLgBBAWBDADgUwjAvAbwFAxgCdVgpEwBzAG3RgC4BtfAmbAD3oEYBfZgXQA0zVFSoBLZBFqNmBbAE8uABl4FBzZCCryK4DDJasxEAGJiwx+KgAm9KIQCuqVTD65euAPIAjAFYkoADoAa1R5CAAKBBR0AEpAgDMQQgBRRGB4KKQ0AGkwrAA+VmZotAgGUtQ8xUQMUPkQBJgoeTRGuGz0PkSxKihUQiyYwuKCAHoxmGYJqYJuWPcF3CA" rel="nofollow noreferrer">Playground link</a></p>
  <p>I am definitely using filter on an array. It should not be complaining. Please, if you know how to fix this, help me</p>