-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem:
I had an issue while generating types for Custom Types with id items
. You can see the logs below.
TypeError: Cannot read properties of undefined (reading 'model')
at file:///Users/alban/[...]/node_modules/.pnpm/[email protected]_zdskoi4kizcgcz3c254mxvxata/node_modules/prismic-ts-codegen/dist/lib/getAPIIDPath.js:11:52
The logs were not very clear and I had to dig into the package to find that items
fits a conditions that triggers the errors.
The code that triggers the error is located at prismic-ts-codegen/dist/lib/getAPIIDPath.js
and specifically this condition :
if (element.id === "items") {
const previousElement = config.path[i - 1];
if (isCustomTypeModelSlice(previousElement.model) || isSharedSliceModel(previousElement.model)) {
return `${element.id}[]`;
}
}
Describe the solution you'd like
This could be avoided in the future by providing a list of forbidden Custom Types IDs, or even better, blocking the creation of Custom Types with forbidden IDs in the first place :)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request