-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created