Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to avoid "no-promise-executor-return" in this situation?

code:

export function sleep(ms: number): Promise<void> {
    return new Promise<void>((resolve) => setTimeout(resolve, ms));
}

Docs link:
no-promise-executor-return

I have tried in many ways to avoid this error.
Unfortunately, to no avail.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is an arrow function thing. () => 0 is the same as function() { return 0 }. So your promise executor does return the response of setTimeout. In order to avoid this wrap the setTimeout call in a function body. (() => { setTimeout(...) }).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading