[@types/express] 4 argument function is not inferred as ErrorRequestHandler in Express.use #60353
Answered
by
alex-kinokon
wirekang
asked this question in
Issues with a @types package
-
import {ErrorRequestHandler} from "express";
import express from "express"
const errorHandler: ErrorRequestHandler = (err,req,res,next)=>{}
const app = express()
app.use(errorHandler) // Works well with typescript
app.use((err,req,res,next)=>{}) // <------- Wrong type here All arguments(err~next) is |
Beta Was this translation helpful? Give feedback.
Answered by
alex-kinokon
Jun 14, 2022
Replies: 2 comments
-
Thanks for the discussion about "express", some useful links for everyone: Pinging the DT module owners: @borisyankov, @CMUH, @puneetar, @dfrankland. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The problem is that the signature using Edit: Pull request |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wirekang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is that the signature using
RequestHandler
has a higher precedence over the one usingRequestHandlerParams
. If you swap that two lines it’s going the work. The problem was introduced by #10025.Edit: Pull request