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:
parent
9f66852d22
commit
03a344da20
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue