title: Typescript generic type for an array input
body: <p>I have a question around generic type for array input. I have a function called <code>useForm</code> and it accepts the following options</p>
  
  <pre><code>export interface DataType {
    [key: string]: FieldValue;
  }
  
  export type FieldValue = boolean | string | string[] | number | {};
  
  export default function useForm&lt;Data extends DataType&gt;(
    { mode, validationSchema, defaultValues, validationFields }: Props&lt;Data&gt; = {
      mode: 'onSubmit',
      defaultValues: {},
    },
  ): UseFormFunctions&lt;Data&gt; {
  }
  
  export interface Props&lt;Data&gt; {
    mode: 'onSubmit' | 'onBlur' | 'onChange';
    defaultValues?: { [key: string]: any };
    validationFields?: string[]; // how do i use generic type here to only allow key from FormData
    validationSchema?: any;
  }
  
  type FormData = {
    firstName: string,
    lastName: string,
  }
  
  const { register } = useForm&lt;FormData&gt;({
    validationFields: ['test'] // should throw error because it's not firstname or lastname
  })
  </code></pre>
  
  <p>i want it to throw an type error when FormData type is not found.</p>