Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
no-floating-promises
rule currently supports to ways to suppress error: adding .catch to the promise and prependingvoid
to the expression. In many cases it's known that returned Promise never throws and having to prepend all call sites withvoid
just to suppress lint errors is tedious and impacts code readability. Rather than polluting all call sites with such annotations it'd be nice to have a marker on the async method/field telling lint that it never throws. Something like this:
classStringProvider{ private_stringPromise:Promise<string>; _resolve: (s: string) =>void=()=>{}; constructor(){ this._stringPromise=newPromise(r=>this._resolve=r); } // tslint:does-not-throw asyncstring():Promise<string>{ returnawaitthis._stringPromise; }}functionrunWithString(provider:StringProvider){ provider.string().then(s=>console.log('ready: '+s));}