Run Sanity TypeGen and troubleshoot type generation issues.
Generates TypeScript types from Sanity schemas and troubleshoots configuration issues.
/plugin marketplace add sanity-io/agent-toolkit/plugin install sanity-plugin@sanity-agent-toolkitI'll help you generate TypeScript types from your Sanity schema.
npm run typegen
# or
npx sanity schema extract && npx sanity typegen generate
Check Configuration
sanity-typegen.json exists and has correct pathstypegen script is in package.jsonRun TypeGen
Troubleshoot Issues
| Issue | Solution |
|---|---|
| "No schema found" | Fix path glob in sanity-typegen.json |
| "Query not typed" | Wrap in defineQuery() |
| Types outdated | Re-run after schema/query changes |
| Import errors | Check sanity.types.ts output path |
{
"path": "./src/**/*.{ts,tsx}",
"schema": "./schema.json",
"generates": "./src/sanity/sanity.types.ts"
}
"Run typegen" "Fix my TypeGen configuration" "Why are my types not updating?"