Docs: no-misused-promises example for "if promise exists" #9066
Labels
awaiting response
Issues waiting for a reply from the OP or another party
documentation
Documentation ("docs") that needs adding/updating
Before You File a Documentation Request Please Confirm You Have Done The Following...
Suggested Changes
The documentation for "no-misused-promises" doesn't provide any example of how to check that a promise itself exists. That is, when
if (promise)
was in fact intended.The standard correct way to check seems to be to check that an object is "thanable", so
if (promise?.then)
. (At the very least it is much clearer about intention)The docs should be updated with examples/guidance for the case where "if promise is defined" was the intended logic.
Affected URL(s)
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-misused-promises.mdx
The text was updated successfully, but these errors were encountered: