Joint session with Vercel: How to build intelligent storefronts (May 15th)

Typegen returns `Array<never>` when filtering with `!= true` on boolean field

9 repliesLast updated: Nov 29, 2025

I’m encountering a strange behavior with the typegen. A qroq query like this (where root is a boolean):
*[_type == 'page' &amp;&amp; root != true]
generates the following:

pages: Array&lt;never&gt;
To fix this, I have to explicitly filter by root == false, but this doesn’t account for page where the boolean is not set.
AI Update

This 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:

Understanding GROQ Boolean Behavior

In GROQ, when filtering booleans:

So 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.

Show original thread
9 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

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.

Related contributions