If I understood you correctly, your solution will depend on the type that the “second” function returns.
In a nutshell, there are at least 2 ways to do it:
- Lambda syntax
- Interfaces (normal and generic interfaces)
I’ve tried to explain all these in the code below, please, check it:
module main
{
export class TestClass
{
// Use lamba syntax as an interface for a return function
protected returnSpecificFunctionWhichReturnsNumber(): () => number
{
return this.specificFunctionWhichReturnsNumber;
}
protected specificFunctionWhichReturnsNumber(): number
{
return 0;
}
// Use an interface to describe a return function
protected returnSpecificInterfaceFunction(): INumberFunction
{
return this.specificFunctionWhichReturnsNumber;
}
// Use a generic interface to describe a return function
protected returnSpecificGenericInterfaceFunction(): IReturnFunction<number>
{
return this.specificFunctionWhichReturnsNumber;
}
}
// An interface for a function, which returns a number
export interface INumberFunction
{
(): number;
}
// A generic interface for a function, which returns something
export interface IReturnFunction<ValueType>
{
(): ValueType;
}
}