【发布时间】:2021-12-13 12:02:15
【问题描述】:
我正在将 Expressjs 项目从 JavaScript 转换为 TypeScript。
初始 JavaScript 模块catchAsyncError.js:
module.exports = theFunc => (req, res, next) => {
Promise.resolve(theFunc(req, res, next)).catch(next);
}
我尝试转换为 TypeScriptcatchAsyncError.ts:
import { Request, Response, NextFunction} from "express";
const theFunc => (req: Request, res: Response, next: NextFunction) => {
Promise.resolve(theFunc(req, res, next)).catch(next);
}
export default theFunc;
但是有一个错误:变量 'theFunc' 隐式具有 'any' 类型.ts(7005)
有人可以建议和解释吗?提前致谢。
【问题讨论】:
-
错误是什么?
-
嗨 Dan P,我已经编辑了我的帖子。包含错误
标签: node.js typescript express