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

Typescript is missing next property in fetchOptions #329

Closed
vvopenka opened this issue Nov 29, 2023 · 2 comments
Closed

Typescript is missing next property in fetchOptions #329

vvopenka opened this issue Nov 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@vvopenka
Copy link

vvopenka commented Nov 29, 2023

Versions

  • @prismicio/client: 7.3.1
  • node: 18.17.1

Reproduction

When I'm trying to initialize client acoarding to the documentation: https://prismic.io/docs/fetch-data-nextjs#caching-with-the-app-router

const client = prismic.createClient("RepoName", {
      accessToken: process.env.PRISMIC_ACCESS_TOKEN,
      fetchOptions: {
        next: { revalidate: 5 }
      }
    });

I keep on getting an error: Type '{ next: { revalidate: number; }; }' is not assignable to type 'RequestInitLike'.

It seems like it's missing in the type:

export interface RequestInitLike extends Pick<RequestInit, "cache"> {

Would it be possible to add it? Or is there a way to define next.revalidate in typescript?

Steps to reproduce

Create a client using the documentation in next.js in typescript.

const client = prismic.createClient("RepoName", {
      accessToken: process.env.PRISMIC_ACCESS_TOKEN,
      fetchOptions: {
        next: { revalidate: 5 }
      }
    });

What is expected?

I should be able to define next.revalidate and next.tags.

What is actually happening?

The code above fails to compile in typescript.

@vvopenka vvopenka added the bug Something isn't working label Nov 29, 2023
Copy link

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

  • Information about your environment and packages you use (Node.js version, package names and their versions, etc.)
    Feel free to attach a copy of your package.json file.
  • Any troubleshooting steps you already went through
  • A minimal reproduction of the issue, and/or instructions on how to reproduce it

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

@angeloashmore
Copy link
Member

Hi @vvopenka, the next options are specific to Next.js, so we'd like to keep it out of the general @prismicio/client package.

Luckily, installing @prismicio/next and using it in your project will fix this issue (see these lines of code). @prismicio/next should be used in your Next.js project for content previews, <PrismicNextLink>, and <PrismicNextImage>.

You can find documentation for @prismicio/next here: https://prismic.io/docs/technical-reference/prismicio-next

Could you give that a try and let me know if that fixes the issue? I'm going to close this issue since it should be working, but we can re-open it if the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants