title: Typescript const with custom type as const
body: <p>We have:</p>
  <pre class="lang-js prettyprint-override"><code>type test = {
    id: number;
    name: string;
  };
  
  const arr: test[] = [{ id: 1, name: 'test-1' }, { id: 2, name: 'test-2' }];
  </code></pre>
  <p>And I want to create a type from an array of objects:</p>
  <pre class="lang-js prettyprint-override"><code>type other = typeof arr[number]['name'];
  
  const another: other = 'test-1'; // Should be 'test-1' | 'test-2' but it's string
  </code></pre>
  <p>If I remove the custom type of <code>arr</code> and use const assertion:</p>
  <pre class="lang-js prettyprint-override"><code>const arr = [{ id: 1, name: 'test-1' }, { id: 2, name: 'test-2' }] as const;
  
  type other = typeof arr[number]['name'];
  
  const another: other = 'test-2'; // Works!
  </code></pre>
  <p>It'll work, but I want to have a type for my <code>arr</code> too.</p>
  <p>How can I create something like this:</p>
  <pre class="lang-js prettyprint-override"><code>type test = {
    id: number;
    name: string;
  };
  
  const arr: test[] = [
    { id: 1, name: 'test-1' },
    { id: 2, name: 'test-2' }
  ] as const;
  
  type other = typeof arr[number]['name'];
  
  const another: other = 'test-1';
  </code></pre>
  <p>I tried to use <code>ReadonlyArray&lt;test&gt;</code> but no luck!</p>