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/prismic-ts-codegen@0.1.11_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 :)
Problem:
I had an issue while generating types for Custom Types with id
items
. You can see the logs below.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 :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 :)