Parameters<T> Parameters (with ConstructorParameters / InstanceType)
Last updated: 2026-10-22
Parameters<T> Parameters (with ConstructorParameters / InstanceType)
Parameters<T> extracts the parameter list of a function type T as a tuple type. With it you can store, pass and forward "a bundle of arguments" without hand-writing tuples like [string, number, string?].
| Group | Utility Types |
|---|---|
| Kind | Type |
| Strict mode | Not required |
ℹ️ Info The editor transpiles TypeScript to JavaScript and runs it (no type checking); see each example's Output for type-check results.
📝 Syntax
type Parameters<T extends (...args: any) => any> =
T extends (...args: infer P) => any ? P : never;
// Usage
type SessionArgs = Parameters<typeof createSession>; // [string, number, string?]
⚙️ Parameters
| T | A function type; in practice almost always obtained via typeof fn |
|---|
Returns:A tuple type matching T's parameters one by one (including optional and rest params); never if T is not a function type.
▶ Example
Edit the code below and click Try it to see the transpiled result:
Output:
session(u-7, 3600s, default)
retry -> session(u-7, 60s, admin)
(Runtime output after transpilation; at the type level SessionArgs is [string, number, string?] — change createSession's signature and the tuple follows)
💡 Notes
ℹ️ Info The implementation also leans on infer, capturing the parameter list as tuple P. Optional parameters appear as string? in the tuple and rest parameters as ...string[].
⚠️ Note Like ReturnType, for overloaded functions only the last overload's parameter list is extracted.
💡 Tip Related tools: ConstructorParameters<T> for constructor params, InstanceType<T> for class instance types, ThisParameterType<T> for this types. This family shines when wrapping third-party APIs.
🏷️ Related Utility Types
💡 Related cases
More cases coming soon.
📚 Related tutorials
❓ FAQ
Q Can the extracted tuple be spread into a call?
A Yes — that is its signature use: createSession(...args). TS checks position, count and types against the tuple; wrong arity is a compile error.
Q How do I append a parameter to a Parameters result?
A Tuples concatenate: type Logged<P extends any[]> = [...P, requestId: string]. Combined with Parameters this builds "original args plus extras" signatures — a staple of decorators and middleware.
Q Does Parameters<typeof Class> work?
A A class is itself a constructor, and typeof Class carries a construct signature. Use the dedicated ConstructorParameters<typeof Class> for constructor args; plain Parameters yields never (no plain call signature matches).