I recently started working with next.js, TypeScript, and Sanity, and everything has been going smoothly so far. I have multiple schemas defined in my project and it works fine in development. The linting checks also do not show any errors. However, when I try to deploy to Vercel, the build fails with the following error:
\`Failed to compile.
./src/pages/admin/\[\[...index\]\].tsx:12:19
Type error: Type '...' is not assignable to type 'Config'.
...
Error: Command "npm run build" exited with 1
Deployment completed
BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1\`
I have identified that the issue lies within the preview section of the schema:
`preview: {
select: {
title: "name",
index: "visibility.index",
inSlides: "visibility.inSlides",
inRestaurants: "visibility.inRestaurants",
img: "logo",
},
prepare(selection: {
title: string;
index: number;
inSlides: boolean;
inRestaurants: boolean;
img: string;
}) {
return {
title: selection.title,
media: selection.img,
subtitle: `POS:${selection.index}, Slide:${
selection.inSlides ? "🟢" : "🔴"
}, List:${selection.inRestaurants ? "🟢" : "🔴"}`,
};
},
},
Without the preview code, the deployment process proceeds as expected. The project works well in development and runs fine with the above code included, and custom schema previews work without any issues.
I am using integrated Sanity Studio in a Next.js page: https://i.sstatic.net/RmMUw.png
config: https://i.sstatic.net/j3wkE.png
While I understand that there are some incompatible types, I am unsure how to adjust them or make them compatible, especially since my code follows the manuals I found and works in the development environment. Any assistance on this matter would be greatly appreciated.