title: TypeScript arguing that an interface is not compatible with generic type T, although T extends that interface
body: <p>I ran into a peculiar behaviour. Better explained by code below or following <a href="https://typescript-play.js.org/?target=2#code/HYQwtgpgzgDiDGEAEAFANiAnkg3gKCUKQgA8YB7AJwBckBLYaiSgMwWQCEQo74BJRszaJcBIuJiVyMAFxIQwTGMIBfPMuJkqteBihQkAdSoBrZriQbxAd1MAKAJRyuPfoNbtR470UoRqAK6UwBaS0nIARAASEGho5BFIaj6qGmoapBQ0SLrcBgBi5OQAPAAqmkzAACYGLrwCTB6IAHxeKfDkwFDUlAHw1FR2VikwAQBGaLxItpRmlHLGs8wANMM+oxNTM3MAwmNydtvMAErQAWjUcqUOSAC8rQpKKUg3OMkppBDwAUyOcihSMB0KAQMqtfDPcR+QLBJDACDWVCA4EQOx+Az3NqQ7wAehxSAAgpQAOYBSCMJDkFhIaiYGDIADkdTcjWEEAZ9AMwHItDydGJoAmyAGSDglHA-nMVJpdMZpQZADo1pD0XYaQALYEKo6UPZ2aiaqDa0zMY2zRw3BzK8TvHwqcRpPBqDpdWgsIp3OEI1AYTAKwoldBYBXMhpCdjNOzwxFBv2LOaOZZIdF3Vroq3u8gKz7fX4OBUGiDANHQVM5TpQchoCAK+LEktQBwOIA" rel="nofollow noreferrer">this typescript playground link</a></p>
  
  <pre><code>namespace Play {
      export interface BasicInterface {
          prop: any
      }
  
      export class Worker { 
          work(): BasicInterface {
              return { prop: "Hello" }
          }
      }
  
      export class Foo&lt;T extends BasicInterface&gt; {
          constructor(
              public worker: Worker,
              public workerCb: (workerResult: T) =&gt; any
          ) {}
          execute(): Promise&lt;T&gt; {
              return new Promise(res =&gt; {
                  // Argument of type 'BasicInterface' is not assignable to parameter of type 'T'.
                  res( this.workerCb(this.worker.work()) )
              }
          }    
      }
  }
  const foo = new Play.Foo&lt;Play.BasicInterface&gt;(new Play.Worker(), res =&gt; res)
  foo.execute().then(res =&gt; console.log(res))
  </code></pre>
  
  <p>The problem occurs at line 20 saying that</p>
  
  <blockquote>
    <p>Argument of type 'BasicInterface' is not assignable to parameter of type 'T'.</p>
  </blockquote>
  
  <p>which is weird because T is defined as <code>T extends BasicInterface</code> in the Foo class declaration, so it should be fully compatible with <code>BasicInterface</code>.</p>
  
  <p>So, question are: why is that and how to fix that?</p>
  
  <p><em>UPDATE</em> I'm even more puzzled now because TS seems to be fine with <a href="https://typescript-play.js.org/?target=2#code/HYQwtgpgzgDiDGEAEAFANiAnkg3gKCUKQgA8YB7AJwBckBLYaiSgMwWQCEQo74BJRszaJcBIuJiVyMAFxIQwTGMIBfZcTJVa8DFChI+YGGkiMq9I2ginq+rj36DW7UeIlSYSALxIARAAkINDRyX3U1cVIKGiQdbn0AMXJyAB4AFQ0mYAATO25eASZnRAA+VzdCeHJgKGpKAFd4aioACmoACwYAc0w5NIBKXCQIojU1PGAIAHdUDEwAOiTyFsmZ9Cx5w2MbVv7+ienZjaWWnElpOV8ATSwAQl8VfqA" rel="nofollow noreferrer">this</a> which is the same(-ish?) thing or I don't see how it's much different...</p>
  
  <pre><code>namespace Play {
      export interface BasicInterface {
          prop: any
      }
      export class Implmentor implements BasicInterface {
          prop = "Hello"
      }
      export class Foo&lt;T extends BasicInterface&gt; {
          constructor(thingy: T) { }
      }
  }
  
  new Play.Foo(new Play.Implmentor())
  new Play.Foo({prop: "Yay!"})
  </code></pre>