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?].

GroupUtility Types
KindType
Strict modeNot 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

TA 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.
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).
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏