title: Import JSON file in TypeScript declaration (*.d.ts files)
body: <p>I am writing a declaration file which should declare a global type and strict to a specific list of string phrases.<br />
  These string phrases are actually part of property keys in an object located in a JSON file.</p>
  <p>Two questions:</p>
  <ol>
  <li>Is it possible to import a JSON file to a declaration file and process it using basic functions, like <code>Object.keys</code> and <code>Array.map</code>?</li>
  <li>Yet, I wonder, if it is even possible to use JS array of strings to define a type in TS?</li>
  </ol>
  <p>Let me give you a code example.</p>
  <p>Let's say we have the following JSON file named <code>data.json</code>:</p>
  <pre><code>{
    &quot;someList&quot;: {
      &quot;#key1&quot;: {&quot;a&quot;: 1, &quot;b&quot;: 2},
      &quot;#key2&quot;: &quot;some value&quot;,
      &quot;#key3&quot;: 1234
    }
  }
  </code></pre>
  <p>Now, I want to create the following declaration file <code>global.d.ts</code>:</p>
  <pre><code>import data from './data.json';
  
  declare global {
    type AllowedKeys = Object(data.someList).map(key =&gt; key.substr(1));
  }
  </code></pre>
  <p>Basically, I need the type to be defined (dynamically as JSON file changes) like this:</p>
  <pre><code>type AllowedKeys = &quot;key1&quot; | &quot;key2&quot; | &quot;key3&quot;;
  </code></pre>
  <p>Any help or at least guidance would be appreciated.</p>