为了练习,我有以下代码:
type WarnUser = {
wasCalled: boolean
(warning: string): void
}
let warnUser: WarnUser = (warning: string) => {
if(warnUser.wasCalled) {
return
}
warnUser.wasCalled = true;
alert(warning)
}
warnUser.wasCalled = false;
但是我得到的错误是:
Property 'wasCalled' is missing in type '(warning: string) => void' but required in type 'WarnUser'.
我不确定现在如何解决此错误。你能帮我吗?