title: keyof for static properties of TypeScript classes
body: <p>Given <a href="http://www.typescriptlang.org/play/#src=function%20getProp%3CT%2C%20K%20extends%20keyof%20T%3E(object%3A%20T%2C%20property%3A%20K)%3A%20T%5BK%5D%20%7B%0D%0A%20%20%20%20return%20object%5Bproperty%5D%3B%0D%0A%7D%0D%0A%0D%0Aclass%20Greeter%20%7B%0D%0A%20%20%20%20private%20greeting%3A%20string%3B%0D%0A%20%20%20%20public%20constructor(message%3A%20string)%20%7B%0D%0A%20%20%20%20%20%20%20%20this.greeting%20%3D%20message%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20public%20greet()%3A%20string%20%7B%0D%0A%20%20%20%20%20%20%20%20return%20%22Hello%2C%20%22%20%2B%20this.greeting%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20public%20static%20warm_greeter()%3A%20Greeter%20%7B%20return%20new%20Greeter(%27good%20o%5C%27%20fellow%27)%3B%20%7D%0D%0A%7D%0D%0A%0D%0Alet%20greeterBuilder%3A%20()%20%3D%3E%20Greeter%20%3D%20getProp(Greeter%2C%20%27warm_greeter%27)%3B%20%2F%2F%20ok%0D%0Aalert(greeterBuilder().greet())%3B%20%2F%2F%20ok%0D%0A%0D%0Aconst%20greeterBuilderName%3A%20keyof%20Greeter%20%3D%20%27warm_greeter%27%3B%20%2F%2F%20does%20not%20build%20%3A(%0D%0AgreeterBuilder%20%3D%20getProp(Greeter%2C%20greeterBuilderName)%3B%20%2F%2F%20does%20not%20build%20%3A(%0D%0Aalert(greeterBuilder().greet())%3B%0D%0A%0D%0A" rel="noreferrer">this code sample in TypeScript playground</a>, I am not able to type properly the <code>greeterBuilderName</code> variable so that it can be passed to getProp utility... <code>keyof Greeter</code> is actually the list of props/methods on <em>instances</em> of Greeter, how can I specify that I want props of the Greeter func itself (<code>prototype</code>, <code>warm_greeter</code>, ... ) ?</p>
  
  <p>In other words, what is the proper type for <code>greeterBuilderName</code> ?</p>
  
  <p>Thanks !</p>
  
  <pre><code>function getProp&lt;T, K extends keyof T&gt;(object: T, property: K): T[K] {
      return object[property];
  }
  
  class Greeter {
      private greeting: string;
      public constructor(message: string) {
          this.greeting = message;
      }
      public greet(): string {
          return "Hello, " + this.greeting;
      }
      public static warm_greeter(): Greeter { return new Greeter('good o\' fellow'); }
  }
  
  let greeterBuilder: () =&gt; Greeter = getProp(Greeter, 'warm_greeter'); // ok
  alert(greeterBuilder().greet()); // ok
  
  const greeterBuilderName: keyof Greeter = 'warm_greeter'; // does not build :(
  greeterBuilder = getProp(Greeter, greeterBuilderName); // does not build :(
  alert(greeterBuilder().greet());
  </code></pre>