【发布时间】:2021-04-14 04:14:40
【问题描述】:
我的问题与TypeScript Express Error Function类似。
但问题的重点不同。为什么 TypeScript 无法识别 Express 的错误处理程序格式的类型?
我还安装了@type/express 模块。
当我改变时
// doesn't work showing type checking error
app.use((err, req, res, next) => {
// SOMETHING
});
进入
// works.
app.use((err: any, req:express.Request, res: express.Response, next: express.NextFunction) => {
// SOMETHING
});
,它可以工作。
【问题讨论】:
标签: node.js typescript express error-handling