Generated sanity.types.ts contains unused types causing TypeScript build failures (TS6196)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start by tracing the generator that produces sanity.types.ts, then reproduce the issue with noUnusedLocals enabled in tsconfig.json and run tsc. Done means generated TypeScript no longer fails with TS6196 for unused helper types while preserving the generated output’s intended use.
Written by the indexing model from the issue text.
Description
When generating types using Sanity, the output file includes helper types that are not referenced anywhere in the file. This causes TypeScript builds to fail when noUnusedLocals is enabled.
Example error:
error TS6196: 'ArrayOf' is declared but never used.
File:
sanity.types.ts
Example snippet:
type ArrayOf<T> = Array<
T & {
_key: string;
}
>;
This type is never used, which breaks strict TypeScript setups.
Steps to reproduce:
- Enable
noUnusedLocals: trueintsconfig.json - Generate Sanity types
- Run
tsc
Expected behavior:
Generated files should:
- Not contain unused types, or
- Be safe to compile under strict TypeScript settings, or
Actual behavior:
TypeScript fails with TS6196 due to unused generated types.
Environment:
- Sanity version: ^5.7.0
- TypeScript version: ^5.9.3
- OS: macOS
- Package manager: pnpm
- Monorepo: Turborepo
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 2
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sanity-io/codegen
-
Difficulty 3/5 1-2 days Newbie friendliness 74/100
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in sanity-io/codegen
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·