You can reuse the signature of a specific function as a parameter to another function using typeof
function foo(str: string): string { return ""}
function baz(f: typeof foo): any {}
But if you want to limit the parameter to just those two specific function, there is no way to express that in typescript (typescript generally goes by structure not by nominal declarations even for objects)
You might be able to do something using specially crafted branded types:
function createBrandedFunction<T, B extends new(...a: any[]) => any>(fn: T, brand: ()=> B) : T & { __brand: B } {
return fn as any
}
const foo = createBrandedFunction(
function (str: string): string { return ""},
()=> class { private p: any}) // we just use a class with a private field to make sure the brand is incompatible with anything else
const bar = createBrandedFunction(
function (str: string): string { return ""},
()=> class { private p: any}) // even a class with the same private is not compatible
function baz(f: typeof foo): any {}
baz(foo) // ok
baz(bar) // err
baz((s)=> "") // err