Restrict generic key type based on lookup type in TypeScript
问题 I'm working on a function that takes two type parameters, T and K . T extends a Record type and K is a key of the first type. Is there a way I can restrict the key type based on its lookup type ( T[K] ) in T ? I have the following types: type FormValue = string | number | boolean | null; type FormValues = Record<string, FormValue>; and the following function: function numericFormHelperFunc<T extends FormValues, K extends keyof T>(key: K, formValues: T) {} Is there a way I can restrict which