dependency on @types/express-serve-static-core induced incompatibility #7001
Replies: 1 comment
|
The TypeScript type definitions for Express are maintained as a part of the DefinitelyTyped project and generally I'd suggest asking there about problems with The reason why your code broke is my recent PR DefinitelyTyped/DefinitelyTyped#74161 that fixed the If you use a specific path with parameters, the typings will try to parse it and set the correct app.get("/user/:id", (req, res) => {
req.params.id // string
}
app.get("/file/*path", (req, res) => {
req.params.path // string[]
}If you don't give any path, then the default type - const handler: RequestHandler = (req, res) => {
req.params.id // string | string[]
}You can also declare the type of const handler1: RequestHandler<{ id: string }> = (req, res) => {
req.params.id // string
}
const handler2 = (req: Request<{ path: string[] }>, res: Response) => {
req.params.path // string[]
} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Environment information
Version:
express 5.2.1
@types/express 5.0.6
Platform:
windows 11 x64 and ubuntu 24.04.3
Node.js version:
24.13.0
Any other relevant information:
What steps will reproduce the bug?
currently express typing have dependency
"@types/express-serve-static-core": "^5.0.0",
which installs @types/express-serve-static-core 5.1.1, which is incompatible
works up to 5.1.0
so massive same errors like this
generated
and this makes the documentation on
https://expressjs.com/en/5x/api.html
useless, in that documentation, same "req.params.id" is used
@types/express-serve-static-core should be fixed
All reactions