Skip to content
qino

Since 0.1.0

Infer

Name the entry types a primitive produces, per view.

A type-only helper that describes a primitive's getter outputs.

src/lib/types.ts
import type { Infer } from "@qino/cms";

type PostTypes = Infer<typeof postCollection>;
type Post = PostTypes["output"];
type DetailPost = PostTypes["views"]["detail"];

Signature

@qino/cms
type Infer<Primitive extends Collection | Tree | Item> = {
  output: Entry; // default view
  views: { [Name in ViewNames]: Entry };
};

Generics

ParameterConstraintDescription
Primitivea defineCollection, defineTree, or defineItem resultThe primitive to describe

Shape

  • output is one entry as returned by the default view. Use Array<Post> for a list.
  • views has one key per declared view, including default, whose type equals output. Without configured views, views is empty.

Outputs include schema transformations, resolved relations at the view's depth, awaited augment output, and _meta.

Notes

  • A primitive that has been widened, such as one annotated as AnyEntry-producing or passed through a generic that drops its inference metadata, resolves to never.
  • Unknown view names are type errors.
  • The descriptor exists only in TypeScript.