Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

"No overload matches this call" using cookieParser with Express 5 and Typescript

未关闭
#138 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
领域
backend

调研方向

首先使用 Express 5 和 TypeScript 重现报告中的 app.use(cookieParser()) 调用,然后检查 cookie-parser 的类型声明,以及该入口点所需的 Express 5 中间件类型。完成的标准是示例无需 any cast 即可通过类型检查,并且现有的包检查仍然通过。

由索引模型根据 Issue 内容生成。

描述

bug

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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

expressjs/cookie-parser 的其他 Issue

查看 expressjs/cookie-parser 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。