Definitelytyped: Express 4.17.3 is breaking express.Response properties

Created on 4 Mar 2020  路  4Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [ ] 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: @puneetar

The recent update of the Express types break all my apps because express.Response obviously no longer has any accessible properties. Example: https://circleci.com/gh/manuelbieh/react-ssr-setup/104

Not sure if I might be using it incorrectly but since I also only see one tiny test with a very specific testcase (sending json() as response) I think there's a chance that this is a bug.

Most helpful comment

Looks like it's this issue repeating once again.

Basically one of the dependencies of @types/express is locked to an old, incompatible version in package-lock.json.

In my case running npm i @types/express-serve-static-core and then npm uninstall @types/express-serve-static-core fixed it as this caused the version in package-lock.json to be updated (4.16.11 -> 4.17.2). Maybe there is a better way to do this (without re-building the entire package-lock file).

All 4 comments

Same here:

ERROR in [at-loader] ./lib/routes/api-note.ts:330:18 
    TS2339: Property 'status' does not exist on type 'Response<any>'.
ERROR in [at-loader] ./lib/routes/api-note.ts:354:18 
    TS2339: Property 'send' does not exist on type 'Response<any>'.

https://travis-ci.org/guyellis/plant/builds/658020632

Looks like it's this issue repeating once again.

Basically one of the dependencies of @types/express is locked to an old, incompatible version in package-lock.json.

In my case running npm i @types/express-serve-static-core and then npm uninstall @types/express-serve-static-core fixed it as this caused the version in package-lock.json to be updated (4.16.11 -> 4.17.2). Maybe there is a better way to do this (without re-building the entire package-lock file).

Looks like @types/express, version 4.17.3 requires the dependency on @types/express-serve-static-core to be with min. version 4.17.1 (where 'Response' is generic), and right now it's "*"

This looks like a duplicate of #40138.
You can fix the outdated @types/express-serve-static-core version as described in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/40138#issuecomment-589867440.

Was this page helpful?
0 / 5 - 0 ratings