Parameters: Extract Function Parameter Types
What You'll Learn
You'll learn how to use the Parameters<T> utility type to extract all parameter types from any function type as a tuple.
The Core Idea
Imagine you have a function, and you want to know exactly what arguments it accepts — not just by reading its signature, but as an actual type you can use elsewhere. Parameters<T> gives you that: it takes a function type and returns a tuple type representing all its parameters in order.
Think of it like creating a mold from an existing object. If someone hands you a function, Parameters creates a perfect type "impression" of what arguments that function expects.
How Parameters<T> Works
Given a function type T, Parameters<T> produces a tuple type where each element matches the corresponding parameter.
function greet(name: string, age: number): void {
console.log(`Hello ${name}, you are ${age}`);
}
type GreetParams = Parameters<typeof greet>;
// type GreetParams = [name: string, age: number]
Notice we use typeof greet — we're extracting the type of the function, not calling it.
Common Use Cases
Forwarding arguments to another function:
function logAndGreet(...args: Parameters<typeof greet>): void {
console.log('Calling greet with:', args);
greet(...args);
}
logAndGreet('Alice', 30); // works perfectly
Type-safe wrappers:
type ParseParams = Parameters<typeof parseInt>;
// type ParseParams = [string: string, radix?: number | undefined]
function safeParse(value: ParseParams[0]): number {
return parseInt(value, 10);
}
What You Get
Parameters<T> always returns a tuple type, even for functions with no parameters:
function noArgs(): void {}
type NoParams = Parameters<typeof noArgs>;
// type NoParams = []
Key Takeaway: Parameters<T> extracts a function's parameter types as a tuple, enabling type-safe argument forwarding and wrapper functions without duplicating parameter definitions.