title: TypeScript - Import JSON file and assign to variable declared with an interface
body: <p>I have the following JSON file (test.json):</p>
  
  <pre><code>{"test":[
      {"file": "f1.txt", "nr":3},
      {"file": "f4.txt", "nr":4},
      {"file": "f7.txt", "nr":7}
  ]}
  </code></pre>
  
  <p>I defined an interface for this JSON structure in TypeScript:</p>
  
  <pre><code>export interface IJsonFiles {
      test: (FileEntity)[];
  }
  
  interface FileEntity{
      file: string;
      nr: number;
  }
  </code></pre>
  
  <p>To make the import statement work in TS I had to create a json.d.ts file with the following content:</p>
  
  <pre><code>declare module "*.json" {
      const value: any;
      export default value;
  }
  </code></pre>
  
  <p>Then I import test.json into my code as follows:</p>
  
  <pre><code>import * as b from '../../assets/test.json';
  let files: IJsonFiles;
  files = b;
  </code></pre>
  
  <p>This results in the following error: </p>
  
  <pre><code>TS2322: Type 'typeof import("*.json")' is not assignable to type 'IJsonFiles'.  Property 'test' is missing in type 'typeof import("*.json")'.
  </code></pre>
  
  <p>Can anybody help?
  Essentially, what I am trying to achieve is:</p>
  
  <p>I want to import JSON files from the file system (don't want to use require!) and I would like to have the JSON structure defined in TS (no implicit any...).</p>