title: Classes & Keyof in Typescript
body: <p>Beginning with TypeScript, I am trying to use <code>keyof</code> to define dynamic properties on a class:</p>
  
  <pre><code>type UserType = {
    id: number,
    name: string,
  }
  
  class Domain&lt;T&gt; {
    _data: T;
    [K in keyof T]: T[K]; // Does not build:
                          // (1) A computed property name must be of type 
                          //     'string', 'number', 'symbol', or 'any'
                          // (2) Cannot find name 'keyof'
  
  
    constructor(data: T) {
      this._data = data;
      Object.keys(data).forEach((key) =&gt; Object.defineProperty(this, key, { get: () =&gt; this._data[key] }));
    }
  }
  
  const joeData: UserType = {
    id: 1,
    name: 'Joe',
  }
  
  const joe = new Domain(joeData); // type: Domain&lt;UserType&gt;
  console.log(joe.id);
  </code></pre>
  
  <p>I did write this code using the same (working) syntax as:</p>
  
  <pre><code>type Foo&lt;T&gt; = {
    [K in keyof T]: T[K];
  }
  </code></pre>
  
  <p>Any hints on how to fix the issue?</p>