🧩 Parameters<T>
Parameters<T> extracts the parameter types of a function and returns them as a tuple.
🔹 Example
function createUser(name: string, age: number) {
return {
name,
age
};
}
type UserParams = Parameters<typeof createUser>;TypeScript infers:
type UserParams = [name: string, age: number];You can use it like this:
const params: UserParams = ["Bhaskar", 25];
createUser(...params);💡 Common Use
Parameters is useful when you want to reuse the parameter types of an existing function, especially with callbacks and utility functions.
Remember:
Parameters<T>→ Gets a function's parameter types as a tuple.