-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-confusing-void-expression] ignoreVoidReturningFunctions ignores generic type returning functions #10289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
🤔 this strikes me as "working as intended". Per the
The |
So basically all returns? Then it should also ignore function foo() {
return console.log("foo")
} because void return is inferred here too. And if that's the expected behavior then this option should just be called |
There's a complicating factor with your examples in the OP - they use type parameters. This means that when we inspect the context of the function we see that it is expecting a It's a tricky detail of type parameters that is very difficult for us to really separate and analyse for. TS doesn't give us information to determine how the type parameters are filled in - it just tells us their type. So we haven't got much choice other than to just treat them as given. OTOH a function like this has no contextual type and has no explicit return type function foo() { return console.log("foo") } And so it is reported as it's assumed it was an accident. If you explicitly annotate the |
I get it now. The docs are indeed correct. It's just the fact that one is ignored and other isn't seems very arbitrary. I would imagine this option to do one of these:
Right now it does 2 and sometimes 3. |
Apologies for nitpicking, but it's not always: it's if a const p = Promise.resolve(1).then<undefined>(() => console.log())
// ~~~~~~~~~~~~~~~~~~~
// Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. Closing as "working as intended", with a subtitle of "inferred type parameters are the zaniest part of a language". Thanks for the discussion! |
Uh oh!
There was an error while loading. Please reload this page.
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://deploy-preview-10067--typescript-eslint.netlify.app/play/#ts=5.5.2&fileType=.ts&code=GYVwdgxgLglg9mABAgogJzXNAeAKgPgAoIBDAGzICMSIBrALkUIEpEBefRXZxgNzhgATRAG8AUIkSkK1OiwDcYgL5ixqDFkIt2nCAgDOcMgFMAdGTgBzQgHI4cAA76bzZorF6w%2BqIgftEAAqYALYw%2BmZoxoZkvMaEAIzMplAAFsZgWqwcUgZGZhbWrmJAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1rI6YDNYyZgHNaANw6UAJvQAexaCiG90YANrhsORNGgdokADSatWLdkiVhnRQDVJUgEqJ8saExEAxWEzL5KvKgY%2BHCIJtgAvuEAuppREUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
No response
Expected Result
Should report both
console.log
sThe correct code should be
or
Actual Result
Doesn't report.
Additional Info
Continued from #8538
The text was updated successfully, but these errors were encountered: