Skip to content

Conversation

@kenjonespizza
Copy link
Collaborator

Adds automatic type regeneration when schema files change during development.

Changes

  • Add chokidar-cli dependency
  • Add dev:typegen script that watches studio/src/schemaTypes/**/*.{ts,tsx} files
  • Add generate-types script to run extract-types and typegen sequentially
  • Watcher runs automatically with npm run dev (via dev:* glob pattern)

How it works

When you run npm run dev, the watcher starts alongside Next.js and Sanity Studio. Any changes to schema TypeScript files trigger the full type generation pipeline: schema extraction → typegen → prettier formatting.

Dependencies

⚠️ This PR depends on #177 being merged first.

@kenjonespizza kenjonespizza requested a review from a team as a code owner January 2, 2026 18:56
@vercel
Copy link

vercel bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
template-nextjs-clean Skipped Skipped Jan 12, 2026 10:51pm

@socket-security
Copy link

socket-security bot commented Jan 2, 2026

@codebravotech
Copy link
Contributor

codebravotech commented Jan 5, 2026

@kenjonespizza as mentioned in slack I think it would be nice if the dev:typegen script:

  • also watches the queries file in the FE because when you use defineQuery or groq , typegen will respect that and generate the query response types, which is suuuper useful. I'd argue that having query result types is actually the most important positive impact of using our typegen tooling, because FE componentry is the place that having pre-defined types saves the most time
  • copies the generated types to somewhere in the studio that they're easy to import/use in studio custom components if desired

@kenjonespizza kenjonespizza marked this pull request as draft January 5, 2026 18:11
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

Successfully merging this pull request may close these issues.

2 participants