[express] Change RequestHandler return type to void#49677
[express] Change RequestHandler return type to void#49677typescript-bot merged 1 commit intoDefinitelyTyped:masterfrom sonallux:express-request-handler-return-type
Conversation
|
@jsone-studios Thank you for submitting this PR! This is a live comment which I will keep updated. This PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Have you considered adding tests to cover the change you're making? Including tests allows this PR to be merged by yourself and the owners of this module. This can potentially save days of time for you. 1 package in this PRCode ReviewsThis PR can be merged once it's reviewed. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 49677,
"author": "jsone-studios",
"headCommitAbbrOid": "1f898c8",
"headCommitOid": "1f898c876e2751345fdce3630c4f5f890337e8e9",
"stalenessInDays": 0,
"lastPushDate": "2020-11-19T09:22:11.000Z",
"lastCommentDate": "2020-11-23T20:43:30.000Z",
"maintainerBlessed": true,
"mergeOfferDate": "2020-11-23T20:41:25.000Z",
"mergeRequestDate": "2020-11-23T20:43:30.000Z",
"mergeRequestUser": "dwrss",
"hasMergeConflict": false,
"isFirstContribution": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "express-serve-static-core",
"kind": "edit",
"files": [
{
"path": "types/express-serve-static-core/index.d.ts",
"kind": "definition"
}
],
"owners": [
"borisyankov",
"19majkel94",
"kacepe",
"micksatana",
"samijaber",
"JoseLion",
"dwrss",
"andoshin11"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "dwrss",
"date": "2020-11-21T15:03:02.000Z",
"isMaintainer": false
}
],
"ciResult": "pass"
} |
|
🔔 @borisyankov @19majkel94 @kacepe @micksatana @samijaber @JoseLion @dwrss @andoshin11 — please review this PR in the next few days. Be sure to explicitly select |
|
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
|
@jsone-studios Everything looks good here. Great job! I am ready to merge this PR (at 1f898c8) on your behalf. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@borisyankov, @19majkel94, @kacepe, @micksatana, @samijaber, @JoseLion, @dwrss, @andoshin11: you can do this too.) |
|
Ready to merge |
|
I just published |
|
@jsone-studios @dwrss I am running in to expressjs/express#4467 So how should I bypass the type check with this PR? My opinion is that the return type should be Could you fix it? @jsone-studios |
You should not bypass the type check. You must handle the case when You can add an explicit app.get("/manifest.webmanifest", (_req, res) => {
getManifest(pwaOptions)
.then(result => res.send(result))
.catch(error => res.status(500).send('Unexpected error'))
});or use the express-async-handler or the express-async-router library. |
|
Thanks for the answer❤ |
…rn type to void by @jsone-studios
Changes the return type of the
RequestHandlerandErrorRequestHandlerfromanytovoidbecause express does not handle any returned value.This will also make
@typescript-eslint/no-misused-promisesrule warn about request handlers that return aPromise, which might result in NodeJS'sUnhandledPromiseRejectionWarningbecause express is not handling a rejectedPromise.Please fill in this template.
Tests are already only using void functions as request handlers.
npm test <package to test>.Select one of these and delete the others:
If changing an existing definition:
ErrorRequestHandler: https://github.com/expressjs/express/blob/508936853a6e311099c9985d4c11a4b1b8f6af07/lib/router/layer.js#L71RequestHandler: https://github.com/expressjs/express/blob/508936853a6e311099c9985d4c11a4b1b8f6af07/lib/router/layer.js#L95tslint.jsoncontaining{ "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using// tslint:disable-next-line [ruleName]and not for whole package so that the need for disabling can be reviewed.