How to get Argument Types from Function in TypeScript ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In TypeScript, the Parameters utility type allows you to extract the types of a function's parameters. This is particularly useful when you want to work with the types of arguments dynamically, enabling functions that operate on any function's parameter types. In this article, we are going to see how to get argument types from functions in Typescript. Syntax:function exampleFunction(arg1: string, arg2: number, arg3: boolean): void { // Function body}// Use the Parameters utility type to get the argument typestype ArgumentTypes = Parameters<typeof exampleFunction>;function logArgumentTypes(...args: ArgumentTypes): void { args.forEach(arg => console.log(typeof arg));}ApproachStart by defining the function from which you want to extract the argument types.Utilize the Parameters utility type to extract the argument types.Design a function to log the types of arguments.Apply the extracted types in your logging function.Example: In this example, the logArgumentTypes function uses the typeof operator to log the type of each argument. JavaScript // Define a sample function function exampleFunction(arg1: string, arg2: number, arg3: boolean): void { // Function body } type ArgumentTypes = Parameters<typeof exampleFunction>; function logArgumentTypes(...args: ArgumentTypes): void { // Log the type of each argument args.forEach(arg => console.log(typeof arg)); } const args: ArgumentTypes = ['Geeks', 22, true]; logArgumentTypes(...args); Output: stringnumberbooleanExample 2: In this example, the printNumberTypes function now correctly logs the type of each number using the typeof operator. JavaScript function addNumbers(a: number, b: number): number { return a + b; } type AddNumbersArgs = Parameters<typeof addNumbers>; function printNumberTypes(...numbers: AddNumbersArgs): void { numbers.forEach(num => console.log(typeof num)); } const result: AddNumbersArgs = [10, 20]; printNumberTypes(...result); Output: numbernumber Comment More infoAdvertise with us Next Article How to get Argument Types from Function in TypeScript ? A amanv09 Follow Improve Article Tags : JavaScript Web Technologies TypeScript Similar Reads How To Get Types From Arrays in TypeScript? In TypeScript, arrays are a common data structure, but sometimes it's necessary to extract the types of elements stored in an array for type-checking or validation purposes. TypeScript provides several ways to extract types from arrays, enabling more type-safe operations.We will explore different me 3 min read How to Create a Generic Type Alias for a Generic Function in TypeScript ? In TypeScript, it is possible to create a generic type alias for a generic function. A generic type alias provides a descriptive name for a function with generic parameters, making it easier to understand the code. It also makes the code reusable and readable especially when you are dealing with com 2 min read How to create conditional types in TypeScript ? Conditional types in TypeScript enable defining types based on conditions, similar to conditional statements in code. They determine different types of values, making functions adaptable to various input types, and enhancing code flexibility and maintainability. Syntax: We can create conditional typ 3 min read How to Specify Return Type in TypeScript Arrow Functions ? To Specify the return type in the TypeScript arrow function, we have multiple approaches. In this article, we are going to learn how to Specify the type in the TypeScript arrow function. Below are the approaches used to Specify the return type in the TypeScript arrow function: Table of Content Expli 2 min read How to call Typescript function from JavaScript ? In this article, we will try to understand all the facts which are associated with how we may call typescript function from JavaScript. TypeScript supports the existing JavaScript function syntax for declaring and calling it within the program or the code snippet. Let us quickly understand how we ma 2 min read Like