-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Disallow calls to async functions from async functions without using 'await' #15195
Conversation
@RyanCavanaugh I think it would very useful also to check calls without await in control flow condition statements Because to catch errors like this I need tslint with slow "strict-boolean-expressions" rule async function bar(){return false}
async function foo() {
if (bar()) {}
while (bar()) {}
do {} while (bar())
var x = bar() ? 1 : 2;
for (var x = 1; i++; bar()){}
switch (bar()) {case bar(): break;}
} |
Hi, Thanks! |
Would love to have this! Currently relying on tslint rule |
This would be especially useful for VSCode users, where |
in light of the discussion about errors vs warnings we should instead move this to tslint. |
It already is in tslint. This is problematic enough to be in TS proper. The tslint plugin in VS code doesn’t catch it and those without a separate linting step in their build pipeline could be shipping very broken code. I hit a MAJOR security issue with not awaiting a Promise— no way should this be downgraded to a warning. |
The TSLint rule also requires type info to be on, which we do not do because it is so much slower (and causes tslint to run out of memory with our repo last I tried it). |
Merging this would prevent things like this:
Which incidentally, is exactly the issue I ran into. Not awaiting promises can cause major, not easily caught security headaches, race conditions and non-deterministic code. Not to mention unhandled Promise rejections are deprecated, and will eventually terminated with a non-zero error code. Again - this is not linting. It's a significant flaw in an otherwise decent type system. Promises should be dealt with based on type, period. If we don't care about how or when they run, we stick |
Will pick this up later |
Fixes #13376