When using InferValue<T>, always feed it query result types, not Sanity schema types. Schema types describe storage, while query results describe the actual data shape (including dereferenced fields).
1. Preferred: Every registered query
Use SanityQueries[keyof SanityQueries] to automatically include every Portable Text shape across all queries. This requires overloadClientMethods in sanity.cli.ts#typegen (on by default).
type PortableTextValue = InferValue<SanityQueries[keyof SanityQueries]>
2. Fallback: Specific named queries
If the union from all queries is too large and slows down type-checking, narrow it to specific query results.
import type {AuthorQueryResult, PostQueryResult} from './sanity.types'
type PortableTextValue = InferValue<AuthorQueryResult | PostQueryResult>
3. Alternative: A scoped mock query
Define a focused GROQ query specifically for type generation to keep the union tight.
import {defineQuery} from 'groq'
const mockQuery = defineQuery(`*[_type in ['author', 'category', 'post']]{ ... }`)
type PortableTextValue = InferValue<SanityQueries[typeof mockQuery]>