Sure. A function's type consists of the types of its argument and its return type. Here we specify that the callback parameter's type must be "function that accepts a number and returns type any":

class Foo {
    save(callback: (n: number) => any) : void {
        callback(42);
    }
}
var foo = new Foo();

var strCallback = (result: string) : void => {
    alert(result);
}
var numCallback = (result: number) : void => {
    alert(result.toString());
}

foo.save(strCallback); // not OK
foo.save(numCallback); // OK

If you want, you can define a type alias to encapsulate this:

type NumberCallback = (n: number) => any;

class Foo {
    // Equivalent
    save(callback: NumberCallback) : void {
        callback(42);
    }
}
Answer from Ryan Cavanaugh on Stack Overflow
🌐
LogRocket
blog.logrocket.com › home › how to pass a typescript function as a parameter
How to pass a TypeScript function as a parameter - LogRocket Blog
May 15, 2025 - Despite the difference in the number of parameters between the two functions, TypeScript allows this assignment due to duck typing. It’s a small note, but it’s important to remember: the number of arguments isn’t utilized in type definitions for functions in TypeScript. Now that we know precisely how to construct types for our functions, we need to ensure we type the functions that we pass in TypeScript.
Discussions

typescript - Is it a bad practice to pass instance as function parameter? - Software Engineering Stack Exchange
So I am learning how to use the factory function in javascript/typescript. I created a to-do list project where I had to pass the instance as a parameter to the function. I wanted to ask is it a bad More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
July 1, 2022
How to pass a value of type Parameters<T> to the function of type T
// <--- This fails to compile! Well, to start with, your if/else clause is the other way around More on reddit.com
🌐 r/typescript
13
19
March 20, 2022
Is it possible to pass strongly-typed functions as parameters in TypeScript? - TestMu AI Community
Is it possible to pass strongly-typed functions as parameters in TypeScript? In TypeScript, I can declare a parameter of a function as a type Function. However, is there a type-safe way to do this? For instance, conside… More on community.testmuai.com
🌐 community.testmuai.com
0
October 2, 2024
How to pass function and arguments of that function as parameters in typescript - Stack Overflow
How can I define a function in typescript that takes a function as the first parameter, and the arguments for that function as the second parameter, while maintaining the strong typing of the funct... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Abuse
stackabuse.com › bytes › passing-functions-as-parameters-in-typescript
Passing Functions as Parameters in TypeScript
August 20, 2023 - In the above example, processGreeting() is a function that accepts a string and a function as parameters. The passed function fn takes in a string as a parameter and return a string. TypeScript provides a feature called "type aliasing" which allows you to create a new name for a type.
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › functions.html
TypeScript: Documentation - More on Functions
TypeScript behaves the same way. Functions with fewer parameters (of the same types) can always take the place of functions with more parameters. Rule: When writing a function type for a callback, never write an optional parameter unless you intend to call the function without passing that argument
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_parameterized_function.htm
TypeScript - Parameterized a Function
The data type of the value passed must match the type of the parameter during its declaration. In case the data types dont match, the compiler throws an error. On compiling, it will generate following JavaScript code. //Generated by typescript 1.8.10 function test_param(n1, s1) { console.log(n1); console.log(s1); } test_param(123, "this is a string");
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-function-as-parameter-with-arguments
How to pass a Function as a Parameter in TypeScript | bobbyhadz
February 27, 2024 - The wrapper function calls the passed-in function with the numbers and returns the result. ... Copied!function wrapper( a: number, b: number, // 👇️ function parameter doMath: (a: number, b: number) => number, ) { return doMath(a, b); } The wrapper function expects a function parameter that takes 2 numbers as arguments and returns a number.
Find elsewhere
🌐
Reddit
reddit.com › r/typescript › how to pass a value of type parameters to the function of type t
r/typescript on Reddit: How to pass a value of type Parameters<T> to the function of type T
March 20, 2022 -

So I'd like something like this:

myFunc(4, "foo", true) // some function that takes a particular set of args

const wrappedFunction = makeWrappedFunction(myFunc)

wrappedFunction(6, "bar", false)

I'd like the type of arg types and return type of wrappedFunction to match the original. I thought I could do:

type Func = (...args: any) => any

async function wrap<T extends Func> (
   fn: T, args?: Parameters<T>
): Promise<ReturnType<T>> {

   // do stuff

   if (!args)
     return await fn()
   else   
     return await fn(...args)    // <--- This fails to compile!
}

The error is that args is not iterable. Now I see that Parameters<T> returns a tuple. But how do I "repass" those args to fn?

Thanks geniuses!!

🌐
Total TypeScript
totaltypescript.com › passing-types-to-functions
How To Pass Types To Functions | Total TypeScript
February 26, 2024 - Learn how to use typescript generics to pass types in constructs like Array and Set .
🌐
Becomebetterprogrammer
becomebetterprogrammer.com › typescript-pass-function-as-a-parameter
TypeScript: Learn How to Pass a Function as a Parameter - Become A Better Programmer
April 25, 2022 - Similar to JavaScript, to pass a function as a parameter in TypeScript, define a function expecting a parameter that will receive the callback function, then trigger the callback function inside the parent function.
🌐
TestMu AI Community
community.testmuai.com › ask a question
Is it possible to pass strongly-typed functions as parameters in TypeScript? - TestMu AI Community
October 2, 2024 - Is it possible to pass strongly-typed functions as parameters in TypeScript? In TypeScript, I can declare a parameter of a function as a type Function. However, is there a type-safe way to do this? For instance, consider the following example: class Foo { save(callback: Function): void { // Perform save operation var result: number = 42; // The save operation returns a number // Is there a way to ensure at compile-time that the callback accepts a single parameter of...
🌐
C# Corner
c-sharpcorner.com › article › how-to-pass-functions-params-in-react-typescript
How to Pass Functions & Params in React + TypeScript
May 27, 2025 - People try to pass data through ... to pass values to functions. You need to do it cleanly. And TypeScript needs to be happy. That’s it. Let’s walk through how to pass parameters in every common React situation. handleClick(5) runs right away as React renders the ...
🌐
Javatpoint
javatpoint.com › typescript-function-parameter
TypeScript Function Parameter - javatpoint
In TypeScript, the accessor property provides a method to access and set the class members. It has two methods which are given below. getter setter getter The getter accessor property is the conventional method which is used for retrieving the value of a variable.
🌐
DEV Community
dev.to › j471n › typescript-functions-4nkp
Typescript: Functions - DEV Community
February 11, 2023 - Writing function is a piece of cake when you know the JS but it gets a little bit complex in typescript. Don’t worry, we will take every aspect of that. We need to define the types of two things in function Parameters & Return Types. Function parameters are the names listed in the function's definition. I'll take an old example that I've mentioned before: // This is a norma JS Function that take two number and returns the sum // Problem is when you call the function you can pass any value // It won't show error because the variable does not have any kind of type function increaseScore(currentScore, increaseBy){ return currentScore + increaseBy; } // Now we define that both parameters have `number` type and it will only take the number // otherwise it will throw an error function increaseScore(currentScore: number, increaseBy: number) { return currentScore + increaseBy; }
🌐
Medium
medium.com › developer-rants › how-to-pass-a-function-type-to-a-function-in-typescript-69d5770f002b
How to safely pass a Function type to a function in Typescript? | by Tamás Polgár | Developer rants | Medium
July 27, 2024 - How to safely pass a Function type to a function in Typescript? Typescript is rather strict about type safety, so if you try to do this: function whatever(callback: Function) {
🌐
Reddit
reddit.com › r/typescript › how to get return type of function passed in as a parameter
r/typescript on Reddit: How to get return type of function passed in as a parameter
December 18, 2023 -

I'm writing a debounce function that takes a function and returns a debounced version. I'd like to maintain the type safety of the original function in the debounced version so I need to infer the types of the parameters and return value of the original function. I'm struggling with the latter.

This is how I'm currently defining the function:

function debounce<T extends (...args: any[]) => unknown>(  
 func: T
)

I'm able to use Parameters<T> to infer the original function's parameter types and enforce those on the returned function.

return (...args: Parameters<T>) => { 
 <debounce stuff>
 return func(...args)
}

How do I get the return type of the original function and enforce that?

🌐
Medium
fab1o.medium.com › named-parameters-in-typescript-288d90f35639
Named Parameters in TypeScript - Fabio Costa
January 30, 2024 - Creating an object to serve as a parameter for a function is called named parameters or named arguments. In general, parameter refers to the function parameter, and argument refers to the value passed in to the parameter.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Passing Functions in React with TypeScript | Pluralsight
February 6, 2019 - As a sample reference, the ClickHandler prop function is currently set up to receive an event parameter of React.MouseEvent type that is applied to an HTMLButtonElement. Any time you click on an element in JavaScript with your mouse, it receives this event property by default. We won’t be needing it in our example. If you did need information about the mouse click event, this is how you would let TypeScript know about the type of event and the type of element that was clicked.