title: Typescript generic type - Type 'keyof T1' cannot be used to index type
body: <p>I have functions to validate forms, I want the function to be in a separate file, but I have a type problem for <code>validationRequirements[fieldName]</code> i getting error <code>Type 'keyof T1' cannot be used to index type '{ name: (value: string) =&gt; boolean; }'.</code></p>
  <p>Here is my validations requirements:</p>
  <pre><code>const validationRequirements = {
      name: (value: string) =&gt; false, //mock
  }
  </code></pre>
  <p>Interface for createValidationObj:</p>
  <pre><code>interface CreateValidationObjI&lt;T1&gt; {
      validation: T1
      fieldName: keyof T1
      value: string
  }
  </code></pre>
  <p>Here I call a function to update the validation object, I pass <code>validationI</code> as typescript argument then i use it as generic:</p>
  <pre><code>const onChangeValidation = ({ value, fieldName }: { value: string; fieldName: keyof typeof validation }) =&gt; {
      const validationObj = createValidationObj&lt;validationI&gt;({ validation, fieldName, value })
  }
  </code></pre>
  <p>Here is the validation function, I want that function in separate:</p>
  <pre><code>const createValidationObj = &lt;T1 extends {}&gt;({ validation, fieldName, value }: CreateValidationObjI&lt;T1&gt;) =&gt; ({
      ...validation,
      [fieldName]: {
          ...validation[fieldName],
          isValid: validationRequirements[fieldName](value), &lt;-- Type 'keyof T1' cannot be used to index type '{ name: (value: string) =&gt; boolean; }'.
          isTouched: true,
      },
  })
  </code></pre>
  <p>Link to example: <a href="https://www.typescriptlang.org/play?ssl=38&amp;ssc=2&amp;pln=36&amp;pc=1#code/JYOwLgpgTgZghgYwgAgG5wDbACZzMAexAElkBvAKGWuRDgFsIAucqm94AZwDVMcWARgQIYIcEG3bUuAFQIBXBAAsI2QcNHjJU6FAJQAspwDmLTmCihj2gL4AaCjYoUERc2j658RFuixfCEmQAXlZ2OkYWSikaLl5-FngMTggHGOlOOUUVNWQklLT03X0jU2QAIgNQZABmZGU4KE5ywup7R2dXEHc-HDxAgCUIAEd5YCgIRnBOELCaCOZkAAo-eUXzSxBjAEoQgD48zALkAHoT+gIEAGsOilBIWEQUAGEJvAh4vu8QAHkBACtiAAeGQARgO0RovQCPmQYO0MGAEAw2AAcgxFlcIABPAgwOGg7SrdYWKy3LruBBvSCfGG-AGzEGg5AQAAekBA2BmZBseyWZA8-n6RDseSRKPRjFFxOQNhYrzENM8wvpgKZe12wQO-O0ADp9dCVa1kABtRHItEYgC6UW07H1usN3zN4stjCtxo4PE8vmV3yGo3Gkwg0xdFslECtK0wa22ntimQUylULAsa2N7Rs206bjAyCIzyU4mMHz9gVm-MF6bF4YxsqiVZJm2MAG4axKMSwsbj8WBsQAHCB4wVfctZ-ZzagUvNOwJ-f6zKmK0tC77zoGzojEPkCzcgUXmjtSxuy7M2IA" rel="nofollow noreferrer">Example</a></p>