8000 Bug: [await-thenable] Also flag unknown · Issue #8301 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: [await-thenable] Also flag unknown #8301

8000
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

Closed
4 tasks done
JoshuaKGoldberg opened this issue Jan 25, 2024 · 3 comments
Closed
4 tasks done

Bug: [await-thenable] Also flag unknown #8301

JoshuaKGoldberg opened this issue Jan 25, 2024 · 3 comments
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.3.3&fileType=.ts&code=CYUwxgNghgTiAEYD2A7AzgF3hkmBc8ArigNYpIDuKA3AFAAUUaAnimPPQJTwC8AfPADetePCgUoASyw5MtAL6cu1IA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AQwHd3K78ALRE3YAjJOiiJo0APbRI4MAF8QSoA&tsconfig=&tokens=false

Repro Code

declare const test: unknown;
(async () => {
  await test
})();

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/await-thenable": "error"
  },
};

tsconfig

{}

Expected Result

There's no guarantee that an unknown-typed value is a Thenable. I'd expect the rule to report a complaint in this case.

Actual Result

No complaint.

Additional Info

await-thenable was first implemented in #192 back in 2019. TypeScript had previously released unknown in TypeScript 3.0 less than a year earlier.

Not detecting unknown was noted by @Tjstretchalot in #8094 (comment).

@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 25, 2024
@bradzacher
Copy link
Member

https://github.com/typescript-eslint/typescript-eslint/blob/main/packages%2Feslint-plugin%2Fsrc%2Frules%2Fawait-thenable.ts#L40-L42

The rule intentionally ignores any and unknown because of your stated reason -- or rather, it inverted - there's no guarantee that an any/unknown isn't a promise.

IMO it's incorrect for the rule to flag this case because the thing might be a promise.

Put another way - if we flag any/unknown:

  • and it IS a promise, then removing the await is the incorrect outcome as removing it will break the code (massive negative)
  • and it IS NOT a promise, then removing the await is correct, but likely won't change code behaviour at all (small positive)

Looking at it this way - by reporting a user uwll either completely and unknowingly break their code, or they'll clean up a mostly stylistic concern... To me that screams "do not report".

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for team members to take a look labels Jan 25, 2024
@JoshuaKGoldberg
Copy link
Member Author

Hmm, that makes sense. I don't feel particularly strongly one way or another tbh. Users haven't been complaining (to my knowledge) at any rate.

cc @Tjstretchalot from #8094 (comment) - sounds like we can just close this out as wontfix and go with what you'd originally proposed for #8094. Thoughts? 😄

@Tjstretchalot
Copy link

Sounds good to me. Will post a comment with the latest state over on #8094 and ask that the blocked tag be removed

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants
0