Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undici-types breaks sbFetch.ts #695

Open
Theofilos-Chamalis opened this issue Nov 27, 2023 · 0 comments
Open

undici-types breaks sbFetch.ts #695

Theofilos-Chamalis opened this issue Nov 27, 2023 · 0 comments
Labels
pending-triage [Issue] Ticket is pending to be prioritised

Comments

@Theofilos-Chamalis
Copy link

When the storyblok-js-client is used in a project that has another package that uses the undici-types package in package-lock.json, the sbFetch.ts throws a type error.

Expected Behavior

No error should be thrown and the project should be able to build with storyblok-js-client without issues.

Current Behavior

Our current Next.js project uses the following dependencies:

  1. @types/node
  2. storybook
  3. commitlint

and when either of these dependencies is upgraded to their latest version, the undici-types package is introduced in our package-lock.json file. Then, when we try building our next.js project, we are greeted with the following error:

./node_modules/storyblok-js-client/src/sbFetch.ts:33:50
Type error: No overload matches this call.
  Overload 1 of 2, '(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>', gave the following error.
    Argument of type 'string | Request | URL | URL | Request' is not assignable to parameter of type 'RequestInfo'.
      Type 'Request' is not assignable to type 'RequestInfo'.
        Property 'duplex' is missing in type 'Request' but required in type 'import("/home/theo/Projects/EF/product-sites/node_modules/undici-types/fetch").Request'.
  Overload 2 of 2, '(input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>', gave the following error.
    Argument of type 'string | Request | URL | URL | Request' is not assignable to parameter of type 'RequestInfo | URL'.
      Type 'Request' is not assignable to type 'RequestInfo | URL'.
        Property 'referrer' is missing in type 'import("/home/theo/Projects/EF/product-sites/node_modules/undici-types/fetch").Request' but required in type 'Request'.
  31 |          this.timeout = $c?.timeout ? $c.timeout * 1000 : 0
  32 |          this.responseInterceptor = $c.responseInterceptor
> 33 |          this.fetch = (...args) => ($c.fetch ? $c.fetch(...args) : fetch(...args))
     |                                                         ^
  34 |          this.ejectInterceptor = false
  35 |          this.url = ''
  36 |          this.parameters = {} as ISbStoriesParams

Steps to Reproduce

  1. Create a new Next.js project using npx create-next-app@latest
  2. Switch to using Node.js v20
  3. Install the following devDependencies: @types/node , storybook , commitlint at their latest versions
  4. Make sure that package-lock.json includes the undici-types package
  5. Try building the project using next build
@alvarosabu alvarosabu added the pending-triage [Issue] Ticket is pending to be prioritised label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

2 participants