SolvedDefinitelyTyped [@types/express]-Type 'P' is not assignable to type 'ParamsArray'

Hi,

I'm getting this error with @types/express version upgrading from 4.17.7 to 4.17.8.

node_modules/@types/express/index.d.ts(99,42): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.
node_modules/@types/express/index.d.ts(108,124): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.
node_modules/@types/express/index.d.ts(109,138): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.`

I'm using latest express: "express": "4.17.1",
and typescript: "typescript": "3.9.7"
I've tried also with the latest typescript version ("4.0.2") and I get the same.

Any help on this issue?

Authors:
@borisyankov
@puneetar
@dfrankland

37 Answers

✔️Accepted Answer

For NPM users, to update your dependency on @types/express-serve-static-core without just blowing away all of package-lock.json, you can use update with the --depth set to include the first level of transitive dependencies:

npm update @types/express-serve-static-core --depth 1

Other Answers:

This is a known issue between these two packages that always comes up when there is a change. Unfortunately, DefinitelyTyped doesn't offer a way to force a minimum version on sub-dependencies, it just lists "@types/express-serve-static-core": "*".
This means that any existing installs with @types/express-serve-static-core will not be updated automatically when @types/express is updated.
As others have mentioned, the fix for this is to update @types/express-serve-static-core one way or another. Deleting the lock file, is my preferred way.

I'm going to recommend this issue be closed as a duplicate and/or as a non-issue.

If you don't want to delete your yarn.lock file check out yarnpkg/yarn#4986 on how to update a specific sub-dependency on yarn

Pick one of :

  • yarn remove @types/express && yarn add @types/express@4.17.8
  • add "resolutions": {"@types/express/@types/express-serve-static-core": "4.17.20" } to package.json and run yarn again
  • delete the @types/express-serve-static-core section from yarn.lock and run yarn again

I deleted package.lock.json and it works well. Thanks!

i forced the v4.17.7 and worked well also for me

More Issues: