title: TypeScript interfaces and dynamic keys
body: <p>I hope it can be done.</p>
  
  <p>The condition is simple - I have 2 types.</p>
  
  <pre><code>type Numbers: Number[];
  type Name: string;
  </code></pre>
  
  <p>Let's say they represent data I retrieved somewhere:</p>
  
  <pre><code>// first provider sends it like this
  { "numbers": [2, 3, 4], "name": "Mike" }
  
  // second uses different API keys, even though the data type is the same
  { "numeros": [ 7, 8 ], "nombre": "Jose" }
  </code></pre>
  
  <p>I have no idea how API creators named their properties, I just know that the returned payload will have 2 different properties - one with <code>Numbers</code> and another with <code>Name</code>.</p>
  
  <pre><code>interface INumbers {
      [propName: string]: Numbers
  }
  
  interface INames {
      [propName: string]: Names
  }
  </code></pre>
  
  <p>I know that index signature is used in cases when property name is unknown. It also specifies that there might be more than 1 property. What I'm trying to figure out is if it's possible to join <code>INumbers</code> and <code>INames</code> together.</p>
  
  <p>I've tried union types, but then the object that implements this interface might have only 1 property. Another idea to extend interfaces did not work as well.</p>
  
  <pre><code>interface IPayload {
      [propName: string]: INumbers | INames
  }
  
  // this will use `[propName: string]` from 1st extended interface, ignoring others
  interface IPayload extends INumbers, INames {}
  </code></pre>
  
  <p>I wonder if it's even can be done. Will appreciate any help.</p>
  
  <p>Thanks!</p>