TypeScript: Infer type of generic keyof
问题 I have types like this: type GenericType<T, K extends keyof T = keyof T> = { name: K; params: T[K] } type Params = { a: 1; b: 2; } const test: GenericType<Params> = { name: "a", params: 2 } When I create an object like test that has property name: "a" I want the type of params to be inferred so that params must be 1 . In my example params has type 1 | 2 which is Params[keyof Params] . But since name is "a" I think it should be possible to limit the type of params to just 1 without specifying