What does it mean when TsLint says "expected callSignature to have a typedef."

TypescriptSignatureTslint

Typescript Problem Overview


I have a function in my code:

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

I'm getting a TsLint error saying:

Message	4	TsLint: expected callSignature to have a typedef.

Can someone explain what this means?

Typescript Solutions


Solution 1 - Typescript

"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;
}

Solution 2 - Typescript

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1679941View Question on Stackoverflow
Solution 1 - TypescriptbasaratView Answer on Stackoverflow
Solution 2 - TypescriptShashikant PanditView Answer on Stackoverflow