我在代码中有一个函数:
networkStop = (action: string = null) => {
this.action[action] = false;
this.net = false;
this.netd = false;
}
我收到了一个 TsLint 错误,错误信息如下:
Message 4 TsLint: expected callSignature to have a typedef.
有人能解释一下这是什么意思吗?
我在代码中有一个函数:
networkStop = (action: string = null) => {
this.action[action] = false;
this.net = false;
this.netd = false;
}
我收到了一个 TsLint 错误,错误信息如下:
Message 4 TsLint: expected callSignature to have a typedef.
有人能解释一下这是什么意思吗?
"缺少类型定义" 请查看:https://github.com/palantir/tslint/blob/master/src/rules/typedefRule.ts 获取详细信息。基本上,由于 callSignature
缺少某些函数注释。
可能的解决方法(显式指定返回类型):
networkStop = (action: string = null):void => {
this.action[action] = false;
this.net = false;
this.netd = false;
}
"typedef": [
false,
"call-signature"
],
tslint.json中的这行代码未强制方法的返回类型。
any
与void
是兼容的,也就是说any
可以接受任何东西,甚至是void
。在这种情况下,我会使用void
;) - basarat