You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-nullable promises shouldn't be allowable in conditions #34717
Non-nullable promises should not be implicitly converted to truthy inside of conditions.
Use Cases
This helps prevent common bugs where promises aren't await-ed (see below).
Examples
asyncisAllowedToDoTheSuperSecretThing(user: User){/* ... */}asyncdoTheSuperSecretThing(ctx: RequestContext){if(isAllowedToDoTheSuperSecretThing(ctx.user)){/* do the super secret thing */}}
should result in an error since isAllowedToDoTheSuperSecretThing returns a non-nullable promise and is never falsey.
Checklist
My suggestion meets these guidelines:
This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
Ryan Cavanaugh (@RyanCavanaugh) This was tagged "Awaiting More Feedback." Does that have any specific meaning or does it just generically mean "this is on the back-burner"?
The downside is that it requires type checking in ESLint which is pretty slow since it generally requires the whole codebase to be checked (whereas when just developing with the language server running, it's pretty fast).
Activity
twavv commentedon Nov 26, 2019
Ryan Cavanaugh (@RyanCavanaugh) This was tagged "Awaiting More Feedback." Does that have any specific meaning or does it just generically mean "this is on the back-burner"?
twavv commentedon Dec 13, 2019
This is available as a plugin for ESLint: typescript-eslint/typescript-eslint#612.
The downside is that it requires type checking in ESLint which is pretty slow since it generally requires the whole codebase to be checked (whereas when just developing with the language server running, it's pretty fast).
andrewbranch commentedon Apr 5, 2021
Implemented in #39175