got: got 12.4.1 dependency cacheable-request does not transpile

Describe the bug

Running TypeScript 4.8.2: Many errors generated on build of form node_modules/@types/cacheable-request/index.d.ts:118:60 - error TS2709: Cannot use namespace ‘ResponseLike’ as a type.

npm explain latest-version cacheable-request@7.0.2 dev node_modules/cacheable-request cacheable-request@“^7.0.2” from got@12.4.1 node_modules/got got@“^12.1.0” from package-json@8.1.0 node_modules/package-json package-json@“^8.1.0” from latest-version@7.0.0 node_modules/latest-version dev latest-version@“^7.0.0” from the root project

Problem remediated with:

"overrides": {
    "latest-version": {
      "got": "12.3.1"
    }
  }

and installing with npm ci if installing with yarn, use --frozen-lockfile as noted by proton-ab below.

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 23 (6 by maintainers)

Commits related to this issue

Most upvoted comments

This is caused by https://github.com/sindresorhus/responselike/releases/tag/v3.0.0 which is breaking for https://github.com/jaredwray/cacheable-request due to removal of @types/responselike and renaming of ResponseLike type to Response.

@sindresorhus thanks for all the help on this and we have published v10.0.0 of cacheable-request. Please let me know if you have any issues with it as there are some breaking changes.

Release Notes for v9: https://github.com/jaredwray/cacheable-request/releases/tag/v9.0.0 Release Notes for v10: https://github.com/jaredwray/cacheable-request/releases/tag/v10.0.0

@sindresorhus Since you’re in this thread, I’ll take the opportunity to say: I really appreciate everything you’ve done for the community. A pleasure to interact at last.

Recommendation for everyone to pin @types/responselike for now.

  "resolutions": {
    "@types/responselike": "1.0.0"
  },

Unless using frozen lockfile, you WILL fetch stub "@types/responselike": "3.0.0" because thoughtfully folks at DefinitelyTyped decided for @types/cacheable-request to depend on "@types/responselike": "*". This will break your application/package regardless of whether you updated or even installed got or not (but you are using --frozen-lockfile on production, right?).

Still facing error

Yep. Wasted an hour tracking this down. Hardcoded

"got": "12.3.0",

@sindresorhus have you plan to port this fix to got@11?

We have now updated cacheable-request to export types which we believe will help with the migration to latest. Next, we will be looking at building a pull request in got. FYI

https://github.com/jaredwray/cacheable-request/releases/tag/v10.0.2

I plan to upgrade cacheable-request, which will fix problem, but they need to make a new release first.

Ok, the DTS maintainers now have moved the latest tag back to @types/responselike@1.0.0. Plz let me know if that fixes your problems.

@BendingBender as of npm 8.3.0, I believe you can do the same thing with “overrides”.