fix: use slice id instead of name for generated TypeScript types#90
Merged
angeloashmore merged 2 commits intomainfrom Apr 8, 2026
Merged
fix: use slice id instead of name for generated TypeScript types#90angeloashmore merged 2 commits intomainfrom
id instead of name for generated TypeScript types#90angeloashmore merged 2 commits intomainfrom
Conversation
`prismic-ts-codegen` generates slice type names based on the slice `id`,
not the `name`. When a slice has a mismatch between its `id` and `name`
(e.g. a slice created by the content modeling agent), the generated
component references a type like `Content.${pascalCase(name)}Slice` that
doesn't exist, causing a TypeScript error.
This fix passes the slice `id` through to the template and uses it for
the `Content.*Slice` type reference, while keeping `name` for the
human-readable component name and comments.
Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f08eb4e. Configure here.
angeloashmore
approved these changes
Apr 8, 2026
Member
angeloashmore
left a comment
There was a problem hiding this comment.
Interesting, apparently this is also a bug in Slice Machine: https://github.com/prismicio/slice-machine/blob/875e77fb251a0e4d79a8b6d96e8df14303f36722/packages/adapter-next/src/hooks/slice-create.ts#L33. Thanks for finding it!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
idandnamedon't match (e.g. when a slice is created by the content modeling agent).Content.${pascalCase(name)}Slice, butprismic-ts-codegengenerates type names based on the sliceid, not thenamelink. This mismatch caused a TypeScript error because the referenced type didn't exist.idthrough to the template and uses it for theContent.*Slicetype reference, while keepingnamefor the human-readable component name and comments.Made with Cursor
Note
Low Risk
Low risk change limited to code generation templates; it only affects newly generated slice components and fixes mismatched TypeScript type references when slice
nameandiddiffer.Overview
Fixes Next.js slice component generation to reference Prismic generated types using the slice
id(e.g.Content.${pascalCase(id)}Slice) instead of the human-readablename.sliceTemplatenow acceptsidandonSliceCreatedpassesmodel.id, preventing TS/JSDoc type errors when a slice’sidandnamedon’t match.Reviewed by Cursor Bugbot for commit 3de5544. Bugbot is set up for automated code reviews on this repo. Configure here.