我在接口(interface)中有一个函数签名,我想将其用作某个类中回调参数的签名。
export interface IGrid {
gridFormat(gridCell: GridCell, grid: Grid): boolean
}
我想做这样的事情:
validateFormat(validator: IGrid.gridFormat) {
// ...
}
这可能吗?
最佳答案
Is this possible?
是的如下图:
export interface IGrid {
gridFormat(gridCell: GridCell, grid: Grid): boolean
}
function validateFormat(validator: IGrid['gridFormat']) { // MAGIC 🌹
// ...
}
关于typescript - 使用接口(interface)函数签名的函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44622399/