const sayHello = async (): Promise<void> => {
// do something
}
with tslint.json configuration:
default
After install [email protected], tslint reports it. In previous version tslint doesn't report this error.
tslint report
void is not a valid type other than return types (invalid-void)tslint(1)
I think async function return Promise<void> is general usage. tslint shouldn't report the error.
invalid-void doc seems don't contain this usage.
Promise<void>
Sure, that seems like a common use case.
How about we add an option to the rule to allow generics to be void. It should allow either true for all generics or a string[] whitelist of allowed ones?
{
"allow-generics": true
}
{
"allow-generics": ["Promise"]
}
That's a good idea to solve this problem. So the invalid-void would be like this? Doesallow-generics means whitelist for generics?
{
"invalid-void": {
true;
"allow-generics": true
}
}
I have another question. why this problem only occurs in version 5.19.0. Is there any change in this rule? Thanks.
Does
allow-genericsmeans whitelist for generics?
Yup!
why this problem only occurs in version 5.19.0. Is there any change in this rule? Thanks.
The invalid-void rule was added in 5.19.0: https://github.com/palantir/tslint/releases/tag/5.19.0. If you're using tslint:all to take in rules, this would have been enabled for you.
Following, running into the same issue with return type of Promise<void>
Most helpful comment
Yup!
The
invalid-voidrule was added in 5.19.0: https://github.com/palantir/tslint/releases/tag/5.19.0. If you're usingtslint:allto take in rules, this would have been enabled for you.