I wan't to do some type mapping with function parameters as belows:
interface TestType {
something: string;
other: number;
}
function func<T, K extends keyof T = keyof T>(key: K, arg: T[K]) { // Here didn't work
// do something
}
// func<TestType>( should auto complete with 'something' or 'other', and arg should be the right type
The func generic type didn't do the right type mapping, how to define func type so that func<TestType> can auto complete with 'something' or 'other', and arg should be the right type? (something -> string, other -> number)