title: Struggling to use TypeScript's infer with generic class
body: <p>I'm trying to use infer to get the type from a generic, but I'm getting an error. I'm most likely applying it wrong... Any help would be appreciated.</p>
  <pre><code>class Foo&lt;X&gt; {
      public make(x: X): FooHandler&lt;this&gt; {
          return new FooHandler(this, x); // Argument of type 'X' is not assignable to parameter of type 'this extends Foo&lt;infer X&gt; ? X : never'
      }
  }
  
  class FooHandler&lt;F extends Foo&lt;any&gt;&gt; {
  
      public constructor(
          public f: F,
          public x: F extends Foo&lt;infer X&gt; ? X : never,
      ) {}
  }
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?#code/MYGwhgzhAEBiD28A8ANAfNA3gKGn6ADgK4BGIAlsNALZgDWApgBQAeAXNCgJQcLwASYAHYATEAwBOSAC4ALchAw58K6BIbSiEoXiEMA7nESDR4iUzkKANNBZcA3LnwBfbK+yhIMPibGSksNAMLNIMot6ISMIAnmhK2E54xGSU0MDwQhDSEkTA0vDmiarJFFQAZrxWRSolqexwQSFhIhHI5EJlkpwYAPyc0Bx6AG6SVSpcWK6uQA" rel="nofollow noreferrer">TypeScript Playground</a></p>
  <p>I'm aware I can add the generic parameter to FooHandler, but I'm trying to avoid this as I'm looking to infer multiple types this way.</p>