Skip to content

fix: use slice id instead of name for generated TypeScript types#90

Merged
angeloashmore merged 2 commits intomainfrom
tomaboro/sync-ts-fix
Apr 8, 2026
Merged

fix: use slice id instead of name for generated TypeScript types#90
angeloashmore merged 2 commits intomainfrom
tomaboro/sync-ts-fix

Conversation

@tomaboro
Copy link
Copy Markdown
Contributor

@tomaboro tomaboro commented Apr 8, 2026

Summary

  • Fixes a TypeScript error that occurs when a slice's id and name don't match (e.g. when a slice is created by the content modeling agent).
  • The generated component was referencing Content.${pascalCase(name)}Slice, but prismic-ts-codegen generates type names based on the slice id, not the name link. This mismatch caused a TypeScript error because the referenced type didn't exist.
  • The 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


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 name and id differ.

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-readable name.

sliceTemplate now accepts id and onSliceCreated passes model.id, preventing TS/JSDoc type errors when a slice’s id and name don’t match.

Reviewed by Cursor Bugbot for commit 3de5544. Bugbot is set up for automated code reviews on this repo. Configure here.

`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
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

@tomaboro tomaboro self-assigned this Apr 8, 2026
Copy link
Copy Markdown
Member

@angeloashmore angeloashmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angeloashmore angeloashmore merged commit d6f53e4 into main Apr 8, 2026
13 checks passed
@angeloashmore angeloashmore deleted the tomaboro/sync-ts-fix branch April 8, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants