ndled rejection void (async () => { await doSomething(); resolve(); })(); }); // Name the async wrapper to call it later const eventEmitter = new EventEmitter(); eventEmitter.on('some-event', () => { const handler = async () => { await doSomething(); otherSynchronousCall(); }; try { synchronousCall(); } catch (err) { handleSpecificError(err); } handler().catch(handleError); }); ``` ### `checksSpreads` If you don't want to check object spreads, you can add this configuration: ```json { "@typescript-eslint/no-misused-promises": [ "error", { "checksSpreads": false } ] } ``` Examples of code for this rule with `checksSpreads: true`: #### ❌ Incorrect ```ts option='{ "checksSpreads": true }' const getData = () => someAsyncOperation({ myArg: 'foo' }); return { foo: 42, ...getData() }; const getData2 = async () => { await someAsyncOperation({ myArg: 'foo' }); }; return { foo: 42, ...getData2() }; ``` #### ✅ Correct ```ts option='{ "checksSpreads": true }' const getData = () => someAsyncOperation({ myArg: 'foo' }); return { foo: 42, ...(await getData()) }; const getData2 = async () => { await someAsyncOperation({ myArg: 'foo' }); }; return { foo: 42, ...(await getData2()) }; ``` ## When Not To Use It This rule can be difficult to enable on large existing projects that set up many misused Promises. Alternately, if you're not worried about crashes from floating or misused Promises -such as if you have global unhandled Promise handlers registered- then in some cases it may be safe to not use this rule. You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule. ## Further Reading - [TypeScript void function assignability](https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void) ## Related To - [`no-floating-promises`](./no-floating-promises.md)