"No overload matches this call" using cookieParser with Express 5 and Typescript
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- express, javascript, node.js, typescript
- 领域
- backend
调研方向
首先使用 Express 5 和 TypeScript 重现报告中的 app.use(cookieParser()) 调用,然后检查 cookie-parser 的类型声明,以及该入口点所需的 Express 5 中间件类型。完成的标准是示例无需 any cast 即可通过类型检查,并且现有的包检查仍然通过。
由索引模型根据 Issue 内容生成。
描述
Environment information
Version:
"dependencies": {
"cookie-parser": "^1.4.7",
"express": "^5.1.0",
}
Platform:
Windows 11
Node.js version:
v20.15.1
Bug
No overload matches this call.
The last overload gave the following error.
Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'PathParams'.ts(2769)
index.d.ts(157, 5): The last overload is declared here.
What steps will reproduce the bug?
Write the following code...
import cookieParser from 'cookie-parser';
import express, {Application} from 'express';
const app: Application = express();
app.use(cookieParser());
The error is caused by Express 5 being more strict with Typescript and wanting return void. You can no longer return anything from your middleware. I've had to replace all code like
return res.status(200);
with
res.status(200);
return // or just get rid of return completely
The only workaround I've found is the following...
app.use(cookieParser() as any);
which is a last resort when using Typescript, as it completely turns off all Typescript type checking.
You need to update this package to work properly with Express 5.
- 主要语言
- JavaScript
- 星标
- 2k
- 派生
- 236
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
expressjs/cookie-parser 的其他 Issue
-
question
难度 4/5 3-5 天 新手友好度 35/100
expressjs/cookie-parser#168 · 5 条评论 ·
-
req.cookies is showing null可能已有人在做 @D-393Patel 于 336 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
expressjs/cookie-parser#128 ·
-
perf: limit cookie parse only on some cookie可能已有人在做 @cesco69 于 548 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 42/100
expressjs/cookie-parser#126 · 1 个 reaction ·
-
future question
难度 5/5 一周以上 新手友好度 25/100
expressjs/cookie-parser#124 · 7 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 20/100
expressjs/cookie-parser#122 · 5 条评论 ·
查看 expressjs/cookie-parser 的全部 Issue
相似的 Issue
-
🔧 in development
难度 2/5 1-3 小时 新手友好度 72/100
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 85/100
-
p5.js 2.0+
难度 2/5 1-3 小时 新手友好度 62/100
processing/p5.js#9295 · 1 条评论 ·
维护者通常 3 天内回复
-
status: needs triage
难度 2/5 1-3 小时 新手友好度 78/100
mastra-ai/mastra#27210 · 1 条评论 ·
维护者通常 1 天内回复
-
content html
难度 2/5 1-3 小时 新手友好度 82/100