compression icon indicating copy to clipboard operation
compression copied to clipboard

Express 5

Open zN3utr4l opened this issue 9 months ago • 7 comments

 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.

app.use(compression())

zN3utr4l avatar Apr 09 '25 13:04 zN3utr4l

Hey @zN3utr4l, can you specify which version of types you're using for Express and Compression?

bjohansebas avatar Apr 16 '25 18:04 bjohansebas

{
    "name": "@types/compression",
    "version": "1.7.5"
}

{
    "name": "@types/express-serve-static-core",
    "version": "5.0.6"
}

{
    "name": "@types/express",
    "version": "5.0.1"
}

zN3utr4l avatar Apr 17 '25 08:04 zN3utr4l

@zN3utr4l if you could provide a reproducible example, that would be great. Compression should work with both Express v5 and v4

bjohansebas avatar May 11 '25 15:05 bjohansebas

I looked into the code and I think the problem is that the import express = require("express"); points to express 4.17.0 instead of 5.x.x

So I think the error is on the "@types/compression" package, which is here

But actually I have no clue how to fix this.

snailcatcher avatar May 20 '25 09:05 snailcatcher

Playing around with the "@types/compression" dev dependency in my project fixes the issue somehow by itself after some attempts.

I do still not know the issue, but somehow it works again :/

snailcatcher avatar May 20 '25 09:05 snailcatcher

i got same error since i got express 5 and "@types/compression": "1.7.5" this appear on : server.use(compression());

someone have a solution ? @snailcatcher i don't understand what u said about "playing around with the "@types/compression" ?

alanbellec avatar Jun 16 '25 23:06 alanbellec

@alanbellec

  • I deleted the node modules folder multiple times
  • I cleaned my npm Cache multiple times
  • I removed and added the package multiple times

And somehow after some time ist started, not showing the error again.

snailcatcher avatar Jun 17 '25 08:06 snailcatcher