title: Import JSON file as const in TypeScript
body: <p>I would like to create a union type from a property of the elements of an array.
  If the array were inline, that would be pretty straightforward using a constant assertion.</p>
  
  <pre><code>const arr = [{ "name": "One" }, { "name": "Two" }] as const;
  
  type name = typeof arr[number]["name"];
  // name = "One" | "Two"
  </code></pre>
  
  <p>Note that without <code>as const</code> the type <code>name</code> becomes equal to <code>string</code>, which is not the intent.</p>
  
  <p>The problem I'm facing is that the array is defined in a separate JSON file.
  I set <code>"resolveJsonModule": true</code> in the TypeScript options so I can import the JSON file in my module.
  But then the compiler widens the type of all properties in the array as there is no <code>as const</code> on the definition.</p>
  
  <pre><code>import * as arr from "./array.json";
  
  type name = typeof arr[number]["name"];
  // name = string (!)
  </code></pre>
  
  <p>Is there a way I can import a JSON file without type widening?</p>