title: TypeScript type not inferred as expected
body: <p>I have a use case where I want to define a set of filters as an object. I want to know which filters there are exactly and have auto completion for it, but in the generic handling of the filters, it can be just be any key as long as it adheres to certain types for their values. I thought to use generics and extends, which works to a certain degree, but there are a few situations where it does not unify based on the type it is extending like I would expect it too. Here is a simplified example of what I attempted and what goes wrong:</p>
  <pre class="lang-js prettyprint-override"><code>type Foo = { [key: string]: boolean | string[] }
  class Bar&lt;F extends Foo&gt; {
    constructor(public arg: F) {}
  }
  const bar = new Bar({ foo: false, bar: [] })
  // Reported as always being false.
  console.log(bar.arg.foo)
  for (const n of bar.arg.bar) {
    // Property 'includes' does not exist on type 'never'. ts(2339)
    n.includes(&quot;x&quot;)
  }
  </code></pre>
  <p>I expected it to infer <code>boolean</code> rather than <code>false</code> (for <code>foo</code>), and <code>string[]</code> rather than <code>never[]</code> (for <code>bar</code>). I assume extends does not unify the types quite as I expected. Is there a way to achieve this in TypeScript? Meaning I would get full knowledge that the instance of <code>Bar</code> has the properties <code>foo</code> and <code>bar</code>, but inside the class itself, it only knows the generic type (as in, some object, rather than knowing its specific keys).</p>