chaijs / chai-http

HTTP Response assertions for the Chai Assertion Library.
http://chaijs.com/plugins/chai-http
633 stars 113 forks source link

TypeScript errors: `Property 'post' does not exist on type 'Agent'` #346

Closed jthemphill closed 1 week ago

jthemphill commented 3 weeks ago

Upgrading from 4.3.0 to 5.1.1 broke our typechecking. Code like this

chai.request
  .agent(this._server)
  .post('/api/preview')

now fails with this error:

error TS2339: Property 'post' does not exist on type 'Agent'.

We think it's because @types/superagent is now in devDependencies, instead of dependencies. I think it should be in dependencies, because your package exports superagent types publicly. Since the superagent types are part of your public types, any package which uses your types should also include the superagent types that you export.

_Originally posted by @jthemphill in https://github.com/chaijs/chai-http/pull/310#discussion_r1833573576_