title: Typescript: A type is not assignable to instance of generic type - both looks the same
body: <pre><code>export type Animal&lt;T extends Kind&gt; = T extends &quot;cat&quot;
    ? CatData&lt;T&gt;
    : DogData&lt;&quot;dog&quot;&gt;
  
  export type Kind = &quot;cat&quot; | &quot;dog&quot;
  
  type CatData&lt;T extends &quot;cat&quot;&gt; = {
    kind: T
    someData: number[]
  }
  type DogData&lt;T extends &quot;dog&quot;&gt; = {
    kind: T
    someData: string[]
  }
  
  const fun = &lt;T extends Kind&gt;(kind: T): Animal&lt;T&gt; =&gt; {
    switch (kind) {
      case &quot;cat&quot;:
        return {
          kind,
          someData: [33],
        }
      default:
        return {
          kind,
          someData: [&quot;data&quot;],
        }
    }
  }
  
  </code></pre>
  <p>For above code I got two errors regarding both cases in switch statement. Both errors are the same:</p>
  <pre><code> test.ts    24   7 error    2322   Type '{ kind: T; someData: string[]; }' is not assignable to type 'Animal&lt;T&gt;'. (lsp)
  </code></pre>
  <p>I don't understand why those types are not assignable to Animal. I'm probably missing something but they look like they are instances of generic Animal type with T provided by function's argument.</p>
  <p>What's wrong with above code?</p>