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

Created on 8 Sep 2020  路  34Comments  路  Source: DefinitelyTyped/DefinitelyTyped

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

Most helpful comment

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

All 34 comments

Same here

I get the same here, with 1 line of context if it can help:

image

same here

which version should I use to resolve this problem?

@love8587 the 4.17.7 works fine

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

The same issue for Nestjs users.

"@nestjs/*": "^7.4.4",
...
"@types/express": "^4.17.7",
"typescript": "^4.0.2"

Specifically, when we update @types/express to ^4.17.7 & @nestjs/platform-express to ^7.4.4.. which is dependent on Express & DefinitelyTyped.
Any ideas?

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

Same @pedrodbaptista
But a PR is appreciated

@mastermatt
Any idea ? The merge you made a week ago broke something, could you have a look ?
Thanks.

Update your version of @types/express-serve-static-core - that fixed it for me.

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.

Ok, thanks for your explanation.

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": "*".

@mastermatt thanks for the answer!

Is that known issue regarding the minimum version on sub-dependencies going to be tackled at any point. If there's an issue for that issue ( :P ) could you provide the link so we keep an eye on it?

Same issue.
Repo has been dockerized and I have got this error when I run 'docker-compose up'.

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

Pick one of :

  • yarn remove @types/express && yarn add @types/[email protected]
  • 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

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

For pnpm users, adding a pnpmfile.js with the following worked for me:

module.exports = {
  hooks: {
    readPackage(pkg) {
      if (pkg.name === '@types/express')
        pkg.dependencies['@types/express-serve-static-core'] = '^4.17.13'
      return pkg
    }
  }
}

This way, you don't need to delete your pnpm-lock.yaml.

alredy had "express": "^4.17.1", and "@types/express": "^4.17.8", but still had a problem
adding @types/express-serve-static-core solved the problem

I had the same issue although I am not using nest nor did I have @types/express-serve-static-core installed. I had to install @types/express-serve-static-core for this issue to go away.
Don't understand why I need this dependency just to compile?

@jsoneaday @types/express-serve-static-core is a dependency of @types/express, see e.g. the dependencies tab on https://www.npmjs.com/package/@types/express, so even if it wasn't directly listed in your package.json it _will_ have been installed in node_modules/ (and listed in package-lock.json/yarn.lock). This is also not related to Nest specifically, anyone using Express in TypeScript can be impacted.

Thank you @textbook Then if this dependency was already installed what is the minimum version of this dependency that is needed to avoid this issue? Thanks again.

This problem is still valid even with versions:
"@types/express": "^4.17.8", "@types/express-serve-static-core": "^4.17.13"

@milenkovic can you provide more info please.
Everyone else here seems to not have the issue once they had @types/express-serve-static-core: 4.17.13 locally.
Can you confirm that the actual version in your node_modules is in fact up to date?

Oi,

Estou recebendo este erro com @ types / express version atualizando de 4.17.7 para 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'.`

Estou usando o 煤ltimo express: "express": "4.17.1",
e o typescript: "typescript": "3.9.7"
Tentei tamb茅m com a 煤ltima vers茫o do typescript ("4.0.2") e obtive o mesmo.

Alguma ajuda neste assunto?

Autores:
@borisyankov
@puneetar
@dfrankland

delete your package.lock or yarn.lock

i have same issue in ubuntu. it seems fine in other environments.
@ types / express version: 4.17.8. @types/express-serve-static-core": "^4.17.13" installed.

Anybody suggest the solution?

I have this same issue, but after installing "@types/express": "^4.17.8", "@types/express-serve-static-core": "^4.17.13" I got a new error below.

node_modules/@types/express-serve-static-core/index.d.ts:30:10 - error TS2305: Module '"../qs"' has no exported member 'ParsedQs'.

30 import { ParsedQs } from "qs";

any suggestions on how to fix it? installing @types/qs did not fix it

@tobslob that's a different issue, please ask it separately

@tobslob that's a different issue, please ask it separately

Alright. Thank you

found a workaround(??) . with yarn.lock, i found somehow automatically latest ver, 4.17.8 of @type/express is forced to install. yarn.lock is auto-generated and you can not edit. 4.17.8 seems to cause this issue as far as i googled

thus, i did manually installed yarn add 4.17.7 ver and seems okay now.

thanks!

Also seeing this issue.

I'm also running into this issue still. I've tried all the above suggestions.

I'm running this with yarn v1.22.5

In my package.json, my packages are

    "@types/express": "4.17.7",
    "@types/express-serve-static-core": "^4.17.13",
    "express": "^4.17.1",

I've also tried.
"@types/express": "^4.17.8",

FIXED: as someone above said, after deleting yarn.lock it worked.... 馃く When in doubt, start deleting your lock files.

I looked at my other projects and copied over the express version - downgrading express to ^4.16.3 and that worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jrmcdona picture jrmcdona  路  3Comments

Loghorn picture Loghorn  路  3Comments

JudeAlquiza picture JudeAlquiza  路  3Comments

Zzzen picture Zzzen  路  3Comments

variousauthors picture variousauthors  路  3Comments