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

Sanity TypeGen with NextJS: the return type of queries is not correctly resolved #2218

Open
lucafaggianelli opened this issue Feb 3, 2025 · 0 comments

Comments

@lucafaggianelli
Copy link

Describe the bug

When generating types definition via Sanity TypeGen in a NextJS project, the return type of queries is not correctly resolved.

Observing the generated types, they're all correct, but the @sanity/client import is not found (it's used in the declare module), the solution is either to install @sanity/client or use next-sanity in declare module.

To Reproduce

Steps to reproduce the behavior:

  1. Generate a new NextJS + Sanity project
  2. Follow the instruction to setup TypeGen
  3. Create a query
  4. The return type of the query is any

Expected behavior

The query return type should be defined and not any

Screenshots

Which versions of Sanity are you using?

@sanity/cli (global)  3.72.1 (up to date)
@sanity/image-url      1.1.0 (up to date)
@sanity/vision        3.72.1 (up to date)
sanity                3.72.1 (up to date)

What operating system are you using?

MacOS

Which versions of Node.js / npm are you running?

pnpm v9.9.0
v22.10.0

Additional context

Add any other context about the problem here.

Security issue?

Any security issues should be submitted directly to [email protected]. In order to determine whether you are dealing with a security issue, ask yourself these two questions:

  • Can I access something that's not mine, or something I shouldn't have access to?
  • Can I disable something for other people? If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just email us at [[email protected]](mailto:[email protected].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant