我想做这样的事情:
function myFunction(arg1: string, arg2: number): boolean {
//some code here
}
interface myInterface {
someOtherProperty: string
myFunction: myFunction // should be the equivalent of (arg1: string, arg2: Number) => boolean
}
这可能吗?
答案 0 :(得分:2)
您可以在类型上下文中使用typeof
来获取任何值的类型:
function myFunction(arg1: string, arg2: number): boolean {
return false;
}
interface myInterface {
someOtherProperty: string
myFunction: typeof myFunction
}