Definitelytyped: [@types/express] error TS2694: '"...@types/express-serve-static-core/index"' has no exported member 'Params'

Created on 8 Dec 2019  路  8Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

  • [x] I tried using the @types/express package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @borisyankov @CMUH

If you do not mention the authors the issue will be ignored.


Environment:
package.json

  • "express": "^4.17.1"
  • "@types/express": "^4.17.2"
  • "typescript": "^3.7.3"

Action to reproduce the error:

tsc

Error encountered:

node_modules/@types/express/index.d.ts(90,50): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'Params'.
node_modules/@types/express/index.d.ts(90,64): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'ParamsDictionary'.
node_modules/@types/express/index.d.ts(90,90): error TS2315: Type 'ErrorRequestHandler' is not generic.
node_modules/@types/express/index.d.ts(99,38): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'Params'.
node_modules/@types/express/index.d.ts(99,52): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'ParamsDictionary'.
node_modules/@types/express/index.d.ts(99,78): error TS2315: Type 'Request' is not generic.
node_modules/@types/express/index.d.ts(100,45): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'Params'.
node_modules/@types/express/index.d.ts(100,59): error TS2694: Namespace '"C:/Users/ttoussaint/path/to/my/project/node_modules/@types/express-serve-static-core/index"' has no exported member 'ParamsDictionary'.
node_modules/@types/express/index.d.ts(100,85): error TS2315: Type 'RequestHandler' is not generic.

What I tried that DID _NOT_ work:

  • rm -rf node_modules + npm i

What I tried that DID work:
In my package-lock.json, I could see the following:

"@types/express-serve-static-core": {
   "version": "4.16.2",
   ...
},

I added @types/express-serve-static-core@latest to my project's dependencies:
package.json

"@types/express-serve-static-core": "^4.17.0"

So now the package-lock.json looks like so:

"@types/express-serve-static-core": {
   "version": "4.17.0",
   ...
},

I cannot make a PR since the package.json file is not in this repository. This is still an issue, since @types/express-serve-static-core should not appear amongst my dependencies.

Most helpful comment

Same problem here.

All 8 comments

thanks, @ttous s This fixed the same issue in my project.

Another approach is to remove all packages that depend on @types/express-serve-static-core and then re-add them.

I wonder if this could be fixed by using a package.json to reference @types/express-serve-static-core@^4.17.1. I don't know enough about how definitely typed works but it appears it is generating a package.json with @types/express-serve-static-core@* which is incorrect.

After a yarn add @types/express-serve-static-core@^4.17.1 (which has resolved to 4.17.2) this still didn't work for me without nuking yarn.lock and my node_modules/ directory.

After that things are fine, I just prefer not having a hard-coded transient dep in my tree.

Same problem here.

Same problem here with yarn

Me funcion贸 esto:

sudo rm -rf node_modules
sudo rm yarn.lock,
sudo yarn

Worked for me:

rm yarn.lock
yarn
yarn start:dev

BTW:

sudo rm -rf node_modules
sudo rm yarn.lock,
sudo yarn

There's no need for sudo in there

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jgoz picture jgoz  路  3Comments

JWT
svipas picture svipas  路  3Comments

jrmcdona picture jrmcdona  路  3Comments

JudeAlquiza picture JudeAlquiza  路  3Comments

demisx picture demisx  路  3Comments