-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
I cannot use generic fn
's Parameters
when calling fn
.
TypeScript Version: 3.9.2
Search Terms:
wrong generic function infer parameters
Code
const functionDict = {
A: (a: any) => ({ a }),
B: (a: any, b: string) => ({ a, b }),
C: (a: any, b: string, c: string) => ({ a, b, c }),
};
type ValueOf<T> = T[keyof T];
export function foo<F extends ValueOf<typeof functionDict>>(
fn: F,
pp: Parameters<F>,
): void {
fn(...pp);
}
Expected behavior:
No error.
Actual behavior:
Error: Expected 3 arguments, but got 0 or more.(2556)
input.ts(4, 9): An argument for 'a' was not provided
Related Issues:
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug