title: Is it possible to get an array types of the record's values in Typescript?
body: <p>I want to obtain all the types of the record's values. For example if I have an object like this:</p>
  <pre><code>{
    'a': 1,
    'b': false
  }
  </code></pre>
  <p>I would like to have a type which contains <code>number</code> and <code>boolean</code>.</p>
  <p>I'm trying to achieve some sort of function mappings without losing types:</p>
  <pre><code>type MyContext = { store: number[]; };
  
  const obj: Record&lt;string, (context: MyContext, ...args: any[]) =&gt; void&gt; = {
      log(ctx: MyContext, msg: string) {
          console.log(msg);
      },
      add(ctx: MyContext, value: number) {
          ctx.store.push(value);
      }
  };
  
  const convert = &lt;TContext&gt;(context: TContext, objectWithFunctions: Record&lt;string, (context: TContext, ...args: any[]) =&gt; void&gt;) =&gt; {
      //omit the first parameter and return a new object with modified functions
      const result: Record&lt;string, (...args: any[]) =&gt; void&gt; = {};
  
      Object.keys(objectWithFunctions).forEach((functionName) =&gt; {
          const func = objectWithFunctions[functionName];
          result[functionName] = (...args) =&gt; func(context, ...args);
      });
  
      return result;
  };
  
  const context = { store: [] };
  const newObj = convert(context, obj);
  newObj.log('some message');
  newObj.add(12);
  newObj.add();//should give an error
  newObj.foo();//should give an error
  console.log(newObj, context.store);
  </code></pre>
  <p><a href="https://typescript-play.js.org/#code/C4TwDgpgBAsiDCB7AdsCAPYUC8UDeUAzsIgE4QBcUyArgLYBGEpA2gLoDcUAvhwFB8AximJREDAFZUAShGGkAJgB5ipAJbIA5gBooACmGoMwKnCRHMugHQ2AhqU2Eqt5CHYBKHAD4oAN0RqCj64eHxQ4VAANoiaBsDopggoaJZQdISaVKoamp6hEQVQhoSIkRBW0bHpufwF3NphEbYKCnEJsEkWwLq+tpE0lNT0TKR5jYVF8VbEZOVgNIQAFnq9-RDutRHcfLwCxViGvsxYuEoAKuYpwF4GycZUF3ep4hJywADqasCLAGI0yIJgGoRDI5GRlNktLpbl0HpdjNY7A4nFAXG42J5sD5-IEvJifPkIgB6ImIOhfKDfaAAMzUpFEYHstjoEDQpFRyAUUHIwBopGQqOoEAA7mJJG8oMKvos0ogFGpaRAudT-oDgchCOMiiIsORCDRIiYoLJ5BDgOoofobFZ7I5nK4PN4-AEgjh8LstQB5cWAqwAawgIEIeheb0+3z+AKBIncVmpZAAorZBMs9Cqo+qAHLM9ZOwkTfZQdOCN2hwHh36q6MaljF6vZlmcLUFPUG4C1qtZnNsN16a22wj4ouqmFXRE25EbLXcKdanl8gWtw38D2FwxXN0EGbkKjsHj8QvIEXeiRuw7HUcIsUSKdH4UnioxPQAchKLLSEEIhFsmggz9vx6SDaLR6AAjAATAB95Ac0rQbCSSyIAaXKaGoRwclAzCkGQfB3g+8aIHo8FEohyFQKh6EuJhpDYaQQgiKU5SVHoeGSLo67GNMJDkBsQA" rel="nofollow noreferrer">Playground</a></p>
  <p>This implementation works but it's lacking of types because <code>any[]</code> constraint is used for the second argument in all the object's functions. Is it a way to somehow infer the types and return some more stricter type rather than <code>Record&lt;string, (...args: any[]) =&gt; void&gt;</code>?</p>