title: Typescript creating interface for object with both dynamic and static keys
body: <p>I'm trying to learn typescript and I've hit a road bump when it comes to the interfaces, I have a object that I want to save one <code>token</code> and one <code>route</code> in as follows</p>
  
  <pre><code>const obj = {
    token: 'thisismytoken',
    '/path/to/somewhere': [{ ... }]
  }
  </code></pre>
  
  <p>The problem I'm having here is: how do I generate the interface for this object?</p>
  
  <p>I've tried:</p>
  
  <pre><code>interface iObject {
    token: string;
    [key: string]: { ... }[]
  }
  </code></pre>
  
  <p>but this generates the error:</p>
  
  <blockquote>
    <p>TS2411: Property 'token' of type 'string' is not assignable to string index type '{ ... }'.</p>
  </blockquote>
  
  <p>same thing happens when I try something like:</p>
  
  <pre><code>interface iRoute {
    val1: number;
    val2: string;
  }
  
  interface iObject extends iRoute {
    token: string;
  }
  </code></pre>
  
  <p>When I try something like:</p>
  
  <pre><code>interface iObject {
    [key: string]: { ... }[] | string;
  }
  </code></pre>
  
  <p>I get the following error when I try to add data to the route variable:</p>
  
  <blockquote>
    <p>TS2339: Property 'push' does not exist on type 'string | { ... }[]'.<br>
    Property 'push' does not exist on type 'string'.</p>
  </blockquote>
  
  <p>is there any other way to go about doing this?</p>