Skip to content

Add option to config to export all types generated #38

@AugusDogus

Description

@AugusDogus

Is your feature request related to a problem? Please describe.

I am in the middle of migrating my company's application from a CRA React 16 app to a T3 Stack Next.js app. Unfortunately, with the amount of technical debt we have I will be unable to make use of the slice-machine for the foreseeable future. While I would love for the code to own the custom types, this just isn't something possible for us at the moment.

Currently, when mapping over the slices on a custom type the slices are typed as PropertyDocumentDataBodySlice.

{property.data.body.map((slice) => {
  return <Slice key={slice.id} slice={slice} />;
})}

In my Slice component, I need to define the props for full type safety.

Ex:

import { type PropertyDocumentDataBodySlice } from "~/types/prismic.types.generated";
import PropertyIntroductionWithFloorplans from "./property/property-introduction-with-floorplans";

export default function Slice({ slice }: { slice: PropertyDocumentDataBodySlice }) {
  if (slice.slice_type === "property_introduction_with_floorplans") {
    return <PropertyIntroductionWithFloorplans slice={slice} />;
  }
}

In the above example, the type PropertyDocumentDataBodySlice is not exported when running prismic-ts-codegen so I have to create my own union by importing the 22 or so types that PropertyDocumentDataBodySlice is a union of. This same example can be applied to practically every custom type and as such leads to some really ugly code.

Describe the solution you'd like

Add a config option to prismicCodegen.config.ts to allow for exporting all types.

Additional context

Our company has platinum level support if it helps to prioritize this issue. Happy to provide additional information privately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions