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

Suggestion: Adding automatic types generation for sanity schema #54

Open
rusbers opened this issue Feb 11, 2025 · 3 comments
Open

Suggestion: Adding automatic types generation for sanity schema #54

rusbers opened this issue Feb 11, 2025 · 3 comments

Comments

@rusbers
Copy link

rusbers commented Feb 11, 2025

First of all, thank you for providing a great TypeScript-friendly template!

I was wondering if there are any plans to integrate automatic type generation for Sanity schemas using the sanity typegen command.

Currently, whenever I modify the schema to fit my project's specific requirements, I need to manually update the TypeScript types and adjust prop types for components accordingly. Automating this process would greatly improve development efficiency and reduce the risk of type mismatches.

Additionally, if automatic type generation is added, it would be great to run it automatically on every dev command, similar to how it's handled in the official Sanity clean template.

Would love to hear your thoughts on this! Thanks for your time and for maintaining this project.

@mitchuman
Copy link
Collaborator

@rusbers Thanks for the kind words and feedback!

Automatic typegen is definitely a consideration I will make. I'll need to refactor how the GROQ queries are currently in place, but I 100% see the benefits for this 👍

The only drawback I have found when trying to implement typegen previously (with the official Sanity package) was the types not being globally accessible (as they are in the current codebase with the types/Sanity.d.ts file). I'll attempt again at this, perhaps in a new git branch some time soon.

@rusbers
Copy link
Author

rusbers commented Feb 11, 2025

@mitchuman Thank you for considering it! I’m looking forward to seeing this improvement. It will greatly enhance the DX 🚀

@nuotsu
Copy link
Owner

nuotsu commented Feb 24, 2025

There's an issue with the typegen command with some of the complex queries I have set up in the codebase and have not been able to get it to work.

Hoping someone else can take s stab at this for the time being.

@nuotsu nuotsu moved this to TODO in SanityPress 2049 Feb 24, 2025
@nuotsu nuotsu added the 🙏 help wanted PRs welcome label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: TODO
Development

No branches or pull requests

3 participants