Update custom types and legacy slices in a nextjs repository

I'm currently migrating a (pretty big) website from gatsby to nextjs using typescript. While this process is taking a few weeks/months I also have to maintain new feature requests on the old platform. Meaning, I need to modify existing slices that are still integrated with gatsby. This means I can not use the new slices and I need to keep the legacy slices until I finish with the next js migration.

My problem is that after updating an existing legacy slice inside a custom type I don't know how to pull the changes in the nextjs project.

  1. I've tried to re-run npx @slicemachine/init@latest but the modified slices do not appear
  2. Do I need to manually change the json structure in the customtypes/article/index.json file?
  3. If I need to manually change the json, how can I regenerate the prismicio-types.d.ts file so that I use the changes in my typescript code?

Hello,

To address your issue, here are the steps you need to follow:

  1. Manually Update JSON Structure:

    • Yes, you will need to manually update the JSON structure in your customtypes/article/index.json file to reflect the changes made to your legacy slices.
  2. Regenerate TypeScript Types:

    • After updating the JSON structure, you can regenerate the TypeScript types using prismic-ts-codegen. Here’s how you can do it:
      • Ensure you have prismic-ts-codegen and its peer dependencies installed:
        npm install --save-dev prismic-ts-codegen @prismicio/types
        
      • Create or update the prismicCodegen.config.ts configuration file at the root of your project:
        import type { Config } from 'prismic-ts-codegen';
        
        const config: Config = {
          output: './types.generated.ts',
          models: ['./customtypes/**/index.json', './slices/**/model.json'],
        };
        
        export default config;
        
      • Run the following command to generate the types:
        npx prismic-ts-codegen
        

This will load your models, convert them to TypeScript types, and save them to a TypeScript file in your project. By default, the output is saved to types.generated.ts.

For more detailed instructions, you can refer to the prismic-ts-codegen Technical Reference - Documentation - Prismic.

If you have any further questions or need additional assistance, feel free to ask!