Bug: [await-thenable] False positive for for await...of
value which is AsyncIterable | Iterable
#10111
Closed
4 tasks done
Labels
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
triage
Waiting for team members to take a look
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.4.3&fileType=.tsx&code=IYZwngdgxgBAZgV2gFwJYHsICoYFNhQAWAMqhLgBQD6IyATvgLYBcMASvgCbABGANrgDK9JgB4AqmWQAOAIJ06wMAD4AlK1nhoAcVzlFydHVG06ZAOYAaGADd0qTtaSdccMrk7KYAbwBQMGDBUXD5OGAAiVEYABwFGPWRgNEwYdEZUZGQPcN8AX19fXAAPaKNkGFBIWEQUDAgYPnRzUnIQClMmAH5WDmBufiERYEYJKTkFJTVWAAU6NNQQXFE7By8-AKhMWgb3EBgAXhgO4ZhOvAISd3ahxlUYVgBtAF0AbgKAuCMKgHdgDJgKJsINs%2BO5UnAdq07usAjAgSB0AIAHSNcwUUHkVT%2BGD5XJAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AQwHd3K78ALRE3YAjJOijdoTSODABfEPKA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
If a value is
AsyncIterable | Iterable
, you need afor await...of
loop to iterate over it, so the linter doesn't complain.Actual Result
await-thenable
reportsIf you apply the suggestion, which in the example is
then the linter is satisfied but the code is broken and the compiler knows it:
Additional Info
It's fine to use
for await...of
to iterate over a sync iterable. It makes sense not to use this construct if you know that you have a sync iterable, but if you may have either an async iterable or a sync one, then you need it.The text was updated successfully, but these errors were encountered: