CultMesh TS: a catalog's value type is never inferred from a value

43ed9396's type test caught it: TypeScript inferred the catalog value type
from a written value or an expected result through the conditional's false
branch, so replace and submitPrediction accepted any value and an annotated
collection read took the annotation as its type. The false branch is now
NoInfer, so only a definition or an explicit type argument decides it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 18:08:38 +02:00
commit 03a344da20

View file

@ -204,11 +204,12 @@ export type CultMeshCollectionWatcher<TDocument> = (
/**
* The value type a catalog lookup yields. An explicit type argument wins; otherwise a CultCache document definition
* names its own value type, and a bare schema descriptor yields `unknown`.
* names its own value type, and a bare schema descriptor yields `unknown`. The value type is never inferred from a
* value or an expected result, so a wrong value is an error rather than a new type.
*/
export type CultMeshCatalogValue<TDocument, TSchema> = [TDocument] extends [never]
? TSchema extends AnyCultCacheDocumentDefinition ? CultCacheDocumentValue<TSchema> : unknown
: TDocument;
: NoInfer<TDocument>;
export interface CultMeshDocumentSchemaDescriptor {
readonly type?: string;