Closed as not planned
Closed as not planned
Description
π Search Terms
"Generic Type","Function","Parameters","ReturnType"
π Version & Regression Information
- This is a bug
- This changed between versions v5.6.0
β― Playground Link
π» Code
type TestType = {
a: {
color: string;
};
b: {
border: string;
};
};
const calls = {
callTest: {
name: 'callTest',
func: <T extends keyof TestType>(k: T) => {
return {} as TestType[T];
},
},
};
type Calls = {
[K in keyof typeof calls]: {
name: K;
func: typeof calls[K]['func'];
};
};
declare const callString = <T extends keyof Calls, F extends Calls[T]['func']>(
qry: Calls[T]['name'],
...args: Parameters<F>
): ReturnType<F>
const result = callString('callTest', 'a' as const)
π Actual behavior
result
type is {color: string} | {border: string}
. The type of the returned result is not mapped to the parameter
- [ ]
π Expected behavior
result
type is {color: string}
. The type should map to parameter 'a'
Additional information about the issue
No response