Consider the code snippet below:
type Params<F extends (...args: any[]) => any> =
F extends ((...args: infer A) => any)
? A
: never;
const fn00 = (name: string, age: number, single: boolean) => true
type test07 = Params<typeof fn00>
How does typeof fn00
meet the Generic constraint of (...args: any[]) => any
.
The typeof
operator in TypeScript only returns strings representing certain types. These include:
"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
For more information on the typeof operator, refer to the following documentation: https://www.typescriptlang.org/docs/handbook/advanced-types.html#typeof-type-guards