私があなたを正しく理解していれば、あなたの解決策は "second"関数が返す型に依存します。
- ラムダ構文私はこれらすべてを説明しようとした
- インタフェース(ノーマルと汎用インターフェース)
:一言で言えば
、それを行うには、少なくとも2つの方法があります以下のコードで確認してください:
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;
}
}
'Function'の戻り値の型はありませんか? – tymeJV
可能であれば、2番目の関数の戻り値の型を指定したいと思います。しかし、「機能」は機能します。 – jordan