title: The type to indicate keys that be set specific type value in Typescript
body: <p>I want to make a type <code>KeyOfType&lt;M, T&gt;</code> for keys that be set specific type value.</p>
  <pre><code>interface MyTypeMap {
      &quot;one&quot;: 1;
      &quot;two&quot;: &quot;hello&quot;;
      &quot;three&quot;: 3;
      &quot;four&quot;: &quot;world&quot;;
      &quot;five&quot;: 5;
  };
  
  type KeyOfType&lt;M, T&gt; = ....; // ?????
  
  type Foo = KeyOfType&lt;MyTypeMap, string&gt;; // 'two' | 'four'
  type Bar = KeyOfType&lt;MyTypeMap, number&gt;; // 'one' | 'three' | 'five'
  </code></pre>
  <p>I tried like below, but it's not working...</p>
  <pre><code>type KeyOfType&lt;M extends {
    [key in keyof M]: any;
  }, T&gt; = M extends {
    [key in infer R]: T;
  } ? R : never;
  </code></pre>
  <p>Is there any way to solve this?</p>