title: How use keyof on object shape rather than explicit type
body: <p>I want to create a type based on the keys of another object in TypeScript.</p>
  <p>I have managed to do this with type inference. But if I use an explicit type <code>Record&lt;string, something&gt;</code> then <code>keyof</code> gives me <code>string</code> instead of a union of the actual keys I used.</p>
  <p><a href="https://i.stack.imgur.com/p5OUN.gif" rel="nofollow noreferrer">TypeScript Playground GIF</a></p>
  <p>Here's example code:</p>
  <pre class="lang-js prettyprint-override"><code>type FileType = &quot;image&quot; | &quot;video&quot; | &quot;document&quot;;
  
  type FileTypeList = Record&lt;string, FileType&gt;
  
  const inferedFileList = {
      a: &quot;image&quot;,
      b: &quot;video&quot;,
      c: &quot;document&quot;
  }
  
  //type files = &quot;a&quot; | &quot;b&quot; | &quot;c&quot;
  type files = keyof typeof inferedFileList;
  
  const explicitelyTypedList : FileTypeList = {
      a: &quot;image&quot;,
      b: &quot;video&quot;,
      c: &quot;document&quot;
  }
  
  //type typedFiles = string
  type typedFiles = keyof typeof explicitelyTypedList;
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAYglgGwgFXNAvFARHAtgQwHMIsoAfbANzgBMIB7UirG%20gYwFdcIA7YLANwAoIaEixEKNABk4AZ2BRMAJQht6AJxoAeBRrg9CAGglJUkAHwj1PBVATzFSqAG8hUD1HwAubHiIkRu6eAEa%20WNR0jEGeUGzhrJzcfFhCAL4iYtAAZpJyzgDWECD02VBZpfaOAkA" rel="nofollow noreferrer">Relevant TypeScript Playground</a></p>
  <p>Is there any way I can use explicit typing in the form <code>Record&lt;string, something&gt;</code> and still get a union type with <code>keyof</code>? I imagine it would be possible with a keyword that behaves like <code>typeof</code> but uses the shape of an object instead of its declared type, but does TypeScript implement such a thing ?</p>