【发布时间】:2023-09-25 16:07:01
【问题描述】:
我不知道为什么会出现错误:
export interface IGrid {
(gridCell: GridCell): boolean
}
在我的课堂上
foo(gridCell: GridCell): boolean {
return true;
}
错误:
类“X”错误地实现了接口“IGrid”。输入“X” 不提供签名'(gridCell: GridCell): boolean'的匹配项
更新:
我在接口的 gridFormat 签名中添加了一个参数。
export interface IGrid {
gridFormat(gridCell: GridCell, x: number): boolean
}
类:
gridFormat(gridCell: GridCell): boolean {
return true;
}
现在的问题是没有错误,该类没有实现具有x: number 参数的功能。我怎样才能让接口正确地要求该功能。
【问题讨论】:
标签: typescript