Object & Function Types

Parameters<T>

Extracts the parameter types of a function type T as a tuple, enabling you to reuse a function's argument types elsewhere.

Definition

TypeScript
type Parameters<T extends (...args: any) => any> =
  T extends (...args: infer P) => any ? P : never;

Examples

Extracting Function Params
function createUser(name: string, age: number, admin: boolean) {
  return { name, age, admin };
}

type CreateUserParams = Parameters<typeof createUser>;
// [name: string, age: number, admin: boolean]

const args: CreateUserParams = ["Alice", 30, true];
Wrapping Third-Party Functions
import { format } from "date-fns";

type FormatArgs = Parameters<typeof format>;

function safeFormat(...args: FormatArgs): string {
  try {
    return format(...args);
  } catch {
    return "Invalid date";
  }
}
Type-safe Event Emitter
type Events = {
  login: (user: string, timestamp: number) => void;
  logout: (user: string) => void;
};

function emit<K extends keyof Events>(
  event: K,
  ...args: Parameters<Events[K]>
) {
  console.log(event, ...args);
}

emit("login", "alice", Date.now());
emit("logout", "bob");

Common Use Cases

  • 1Creating wrapper functions with matching signatures
  • 2Type-safe event emitters and message buses
  • 3Deriving test mock parameter types from real functions
  • 4Reusing argument types without manual duplication
  • 5Building higher-order function utilities

Understanding Parameters<T>

Parameters<T> extracts the parameter types of a function type T and returns them as a tuple type. It uses the infer keyword within a conditional type to capture the argument list of the function signature.

This utility type is invaluable when you need to create functions that wrap or delegate to other functions. Instead of manually copying the parameter types—which leads to duplication and drift—you can derive them directly from the original function. If the original function's signature changes, all derived types automatically update.

A powerful pattern is building type-safe event systems. By defining an events map where each key maps to a function signature, you can use Parameters<Events[K]> to ensure that emit calls have exactly the right arguments for each event type. This catches mismatches at compile time rather than at runtime.

Parameters also works with typeof to extract types from value-level functions. This is particularly useful with third-party library functions where the parameter types might be complex and not individually exported. Rather than trying to import internal types, you can write Parameters<typeof thirdPartyFunction>.

The result is a tuple type, which means you can index into it: Parameters<typeof fn>[0] gives you the type of the first parameter. This granularity enables selective reuse—you might want only the first parameter's type for a related function while ignoring the rest.

Parameters pairs naturally with ReturnType. Together they fully describe a function's type contract, enabling advanced patterns like memoization wrappers, logging decorators, and retry utilities.

Related Types

More Object & Function Types

Explore TypeScript Types

Browse our complete reference of 30 TypeScript utility types with definitions, examples, and explanations.