title: TypeScript: Require all keys of a type as array
body: <p>I'd like to generate an array of strings that should always contain all keys of a given type.</p>
  
  <pre><code>interface User {
    id: number
    name: string
  }
  
  // should report an error because name is missing
  const allUserFields: EnforceKeys&lt;User&gt; = ["id"];
  
  type EnforceKeys&lt;T&gt; = any; // what to use here?
  </code></pre>
  
  <p>I've tried <code>type EnforceKeys&lt;T&gt; = Array&lt;keyof T&gt;</code> and while that type gives me auto-completion and reports illegal keys, <strong>it doesn't enforce all keys</strong>. However, that's what I want.</p>
  
  <p>And here is the background why I want to have it.</p>
  
  <pre><code>// this type contains updatable fields and can be given to api/client interface
  type UserUpdate = Pick&lt;User, "name"&gt;
  
  // this should always contain all keys to keep it in sync 
  const updateableFields: EnforceKeys&lt;UserUpdate&gt; = ['name']
  
  // simple example for using the array to just update updatable fields
  function updateUser(user: User, update: UserUpdate) {
    updateableFields.forEach(field =&gt; {
      user[field] = update[field];
    });
    // ...
  }
  </code></pre>