Course contentsShow
← TypeScript
Lesson 702 of 1,79616. Utility TypesFree lesson

Parameters with Rest and Optional Args

See how Parameters represents optional parameters, defaults, and rest parameters in the resulting tuple.

Parameters with Rest and Optional Args

What you'll learn: How the Parameters<T> utility type accurately represents optional parameters, default values, and rest parameters in the extracted tuple type.


When you extract a function's parameter types using Parameters<T>, TypeScript doesn't just give you a simple list—it preserves the full signature details, including which parameters are optional, which have defaults, and whether there's a rest parameter.

How Optional Parameters Appear

Optional parameters (marked with ?) show up as union types with undefined in the resulting tuple:

type Fn = (name: string, age?: number) => void;
type Params = Parameters<Fn>;
// [name: string, age?: number | undefined]

Notice the age parameter remains optional in the tuple type. You could destructure this as [string] or [string, number].

How Default Parameters Are Represented

Parameters with default values are treated as optional in the extracted type:

type Greet = (greeting: string = "Hello") => string;
type GreetParams = Parameters<Greet>;
// [greeting?: string | undefined]

TypeScript sees default parameters as optional because you can omit them when calling the function.

How Rest Parameters Appear

Rest parameters become array types at the end of the tuple:

type Logger = (prefix: string, ...messages: string[]) => void;
type LogParams = Parameters<Logger>;
// [prefix: string, ...messages: string[]]

The rest element preserves both its position and its array nature in the extracted tuple type.

Key Takeaway: Parameters<T> preserves the full parameter signature including optional markers (?), default parameter optionality, and rest parameter spreading—giving you a tuple type that accurately mirrors the function's calling signature.