
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a known issue that was fixed in the Sanity CLI's type evaluator in April 2024. The problem occurs when using != true with boolean fields in GROQ queries - the typegen incorrectly infers Array<never> because it doesn't properly handle the case where boolean fields can be true, false, or undefined.
The issue you're experiencing is that in GROQ, root != true should match documents where root is either false or undefined (not set), but the type evaluator was incorrectly narrowing this to an impossible type (never).
According to the discussion on Sanity Answers, this was fixed and released in late April 2024. To get the fix:
Update your Sanity CLI: Delete your lock file (package-lock.json, yarn.lock, or pnpm-lock.yaml) and reinstall dependencies to pick up the latest version of the CLI with the fixed type evaluator.
Regenerate types: Run npx sanity typegen generate after updating.
In GROQ, when filtering booleans:
root == true matches only documents where root is explicitly trueroot == false matches only documents where root is explicitly falseroot != true matches documents where root is false OR undefined/null!root matches documents where root is false, undefined, or nullSo your original query *[_type == 'page' && root != true] is actually the correct approach for finding pages that aren't root pages, including those where the field isn't set. The typegen just wasn't handling it properly before the fix.
If you're still experiencing this issue after updating, make sure you're using a recent version of the Sanity CLI (v3.37.0 or later should include the fix). The fix was confirmed by Sindre Gulseth from the Sanity team, who mentioned that deleting the lock file would pick up the latest version as it was released as a minor version update.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store