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

Generating TS types not working when importing defineQuery from next-sanity #1654

Open
Jdruwe opened this issue Aug 20, 2024 · 1 comment
Open

Comments

@Jdruwe
Copy link

Jdruwe commented Aug 20, 2024

I was reading the updated docs on generating types: https://github.com/sanity-io/next-sanity?tab=readme-ov-file#generate-typescript-types. I updated both next-sanity & sanity to the latest versions and tried generating the types. I noticed that when I import define query like this, it doesn't work

import { defineQuery } from 'next-sanity';

When I import it directly from groq it does work:

import { defineQuery } from 'groq';

Expected behavior

image

Correct return type VS:

image

Notice Promise of the actual result vs any when using defineQuery from next-sanity.

@Jdruwe Jdruwe changed the title Generating TS type not working when importing defineQuery from next-sanity Generating TS types not working when importing defineQuery from next-sanity Aug 20, 2024
@stipsan
Copy link
Member

stipsan commented Oct 15, 2024

Does it work again if you install @sanity/client explicitly? We've seen that with some package managers, like pnpm, peer dependencies are not hoisted by default. And our auto type gen which uses declare module "@sanity/client" doesn't work, since you don't have a ./node_modules/@sanity/client folder 🤔

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

2 participants