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

2

91

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?

Kristynkrock answered 23/8, 2014 at 6:33 Comment(0)
V
137

"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;
}
Veilleux answered 23/8, 2014 at 6:48 Comment(5)
Can you tell me is putting :any after the () the same as void? In this example it returns nothing so how could I specify that? ThanksKristynkrock
Not its not the same. But any is compatible with void i.e. any can take anything even void. I would use void in this case ;)Veilleux
For the void do I just enter :void instead of :any or is there a special syntax ?Kristynkrock
it was useful for meDoorbell
How to use this for a getter function?Encephalomyelitis
P
24

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.

Particia answered 17/11, 2020 at 13:20 Comment(1)
this is not the answer for this questionDesilva

© 2022 - 2024 — McMap. All rights reserved.