routes/index.ts has TypeScript errors, eslint(@typescript-eslint/no-misused-promises) - express-generator-typescript

./sample-output/express-gen-ts/src/routes/index.ts shows errors, eslint(@typescript-eslint/no-misused-promises), for the handler arguments in the router matcher functions:

Screen Shot 2021-04-27 at 13 28 45

Promise returned in function argument where a void return was expected.

Asked Sep 29 '21 00:09
avatar derekschinke

2 Answer:

You'll have to take away that linting option no-misused promises. It's very common to have pass asynchronous functions to express routes.

Answered May 14 '21 at 23:02
avatar  of seanpmaxwell

FYI, this rule included in "plugin:@typescript-eslint/recommended-requiring-type-checking" you can check this code from package.json > eslintConfig > extends. If you do want disable this linting option, just add this "@typescript-eslint/no-misused-promises": 0, on package.json > eslintConfig > rules.

If you want to check all the rules included in "recommended-requiring-type-checking", you can find its list from node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-requiring-type-checking.js

Answered May 21 '21 at 05:28
avatar  of imbrok