title: TypeScript: "extends" string literal type check not working
body: <p>When trying to type check the dependency between keys and values in an object, I try to define <code>MyObject</code> as:</p>
  <pre><code>type Key =  AKey| BKey
  type AKey = `A${string}`
  type BKey = `B${string}`
  type Item&lt;Key&gt; = 
     Key extends AKey ? {a:string} : 
     Key extends BKey ? {b:number} : 
     {}
  type MyObject = {[key:Key]:Item&lt;Key&gt;}
  </code></pre>
  <p>There is no error, however invalid inputs are accepted without errors:</p>
  <pre><code>let test1:MyObject = {&quot;Afoo&quot;:{a:&quot;yes&quot;}}
  let test2:MyObject = {&quot;Afoo&quot;:{b:1}} // should fail
  let test3:MyObject = {&quot;Bbar&quot;:{a:&quot;no&quot;}} // should fail
  let test4:MyObject = {&quot;Bbar&quot;:{b:2}}
  </code></pre>
  <p>It looks like <code>extends</code> is not working with string literal types or is it something else?</p>
  <p>I know about <code>as const</code> for a closed set of keys but this doesn't apply here as I need the keys set to be infinite.</p>