title: Index signature missing in type: why is this an error?
body: <p>Take the following typescript:</p>
  
  <pre><code>type Primitive = undefined | null | boolean | number | string;
  
  // A POJO is just supposed to be your typical object, with nothing 
  // fancy, but where we don't exactly know what's in it.
  interface POJO {
      [key: string]: Primitive | POJO;
  }
  </code></pre>
  
  <p>Okay, so the POJO is just supposed to represent some generic object, but a nice simple one. Might be something I'm going to <code>JSON.stringify</code> or whatever. Now here's the offending code:</p>
  
  <pre><code>// Some functions implemented elsewhere...
  declare function post(path: string, data: POJO): Promise&lt;Response&gt;;
  declare function getToken(): string;
  
  type LinkOrMessage = {link: string} | {message: string};
  
  function specialPost(path: string, data: LinkOrMessage): Promise&lt;Response&gt; {
      const body = {
          ...data,
          token: getToken(),
      };
  
      // Error: see below...
      return post(path, body);
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>Argument of type '{ token: string; link: string; } | { token: string; message: string; }'
  is not assignable to parameter of type 'POJO'.
  
  Type '{ token: string; link: string; }'
  is not assignable to type 'POJO'.
  
  Index signature is missing in type '{ token: string; link: string; }'
  </code></pre>
  
  <p>Wat? Moreover, if we change the <code>LinkOrMessage</code> type so that it's not a union, e.g. simplify it to just <code>{link: string}</code>, the error goes away! Same if we simplify to just <code>{message: string}</code>. So clearly each type in the union is assignable to <code>POJO</code>, yet the union is itself not?</p>
  
  <p>Can someone shed some light on this behavior?</p>