title: In Typescript, how to import json and dynamically lookup by key?
body: <p>In typescript 3.0.3, I import a json file like this:</p>
  
  <pre><code>import postalCodes from '../PostalCodes.json';
  </code></pre>
  
  <p>It has this format:</p>
  
  <pre><code>{
      "555": { "code": 555, "city": "Scanning", "isPoBox": true },
      "800": { "code": 800, "city": "Høje Taastrup", "isPoBox": true },
      "877": { "code": 877, "city": "København C", "isPoBox": true },
      "892": { "code": 892, "city": "Sjælland USF P", "isPoBox": true },
      "893": { "code": 893, "city": "Sjælland USF B", "isPoBox": true },
      "897": { "code": 897, "city": "eBrevsprækken", "isPoBox": true },
      "899": { "code": 899, "city": "Kommuneservice", "isPoBox": true },
      "900": { "code": 900, "city": "København C", "isPoBox": true },
      "910": { "code": 910, "city": "København C", "isPoBox": true },
      "917": { "code": 917, "city": "Københavns Pakkecenter", "isPoBox": true },
  
  ... and so on
  </code></pre>
  
  <p>I want to use it like this:</p>
  
  <pre><code>// first.postalCode is of type string
  const x = postalCodes[first.postalCode];
  </code></pre>
  
  <p>I get the error: "Element implicitly has an 'any' type because type '...very long type signature...' has no index signature."</p>
  
  <p>Is there a way to get this working with the automatically generated json types, so that I can look up a postal code by it's string key dynamically?</p>
  
  <p>My best approach right now is to have an intermediary ts file like: </p>
  
  <pre><code>import postalCodes from './PostalCodes.json';
  
  export const PostalCodesLookup = postalCodes as {
      [key: string]: { code: number, city: string, isPoBox: boolean }
  };
  </code></pre>