当 TsLint 表示“ ExpatedcalSignature 拥有 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.

有人能解释一下这是什么意思吗?

80724 次浏览

"Missing Type definition" See : https://github.com/palantir/tslint/blob/master/src/rules/typedefRule.ts for details. Basically some annotation (for a function because callSignature) is missing.

Probably the fix (specify the return type explicitly) :

networkStop = (action: string = null):void => {
this.action[action] = false;
this.net = false;
this.netd = false;
}

To avoid the build error. in the tslint.json file write code like:-

"typedef": [
false,
"call-signature"
],

This line of code in tslint.json does not make the return type of method required.