Skip to content

Generate TypeScript types from CND definitions #702

Description

@romain-pm

Part of EPIC #698.

Component props interfaces are maintained by hand next to the CND definition, and drift silently:

[hellojahia:blogPost] > jnt:content, mix:title, jmix:mainResource
 - body (string, richtext) mandatory
 - publicationDate (date)
 - category (string, choicelist[blogCategories])
interface Props {
  "jcr:title": string;      // hand-written mirror of the CND
  "body": string;
  "publicationDate"?: string;
  "category"?: string;
}

Renaming or retyping a CND property breaks nothing at build time — views keep compiling against the stale interface. By contrast, Astro derives content types from the zod schema: change the schema, every consumer re-type-checks on save.

Proposal: a build step (vite plugin or codegen script) that parses the module's .cnd files and emits props interfaces (mandatory vs optional, i18n, multiple, date/weakreference mappings, mixin inheritance), e.g. into a generated .d.ts importable as jahia:types/hellojahia:blogPost or similar. Fold Content Editor form types in later if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions