Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/next/src/build/static-paths/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ export async function buildPagesStaticPaths({
}
// For the object-provided path, we must make sure it specifies all
// required keys.
else {
else if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The else if (... || entry === null || ...) validation branch in buildPagesStaticPaths produces a TypeScript TS2367 error and prettier violations, breaking the type-check/build.

Fix on Vercel

throw new Error(
`Invalid path "${String(entry)}" returned from \`getStaticPaths\` in ${page}.\n` +
`Each path must be a string or an object of shape { params: { [key: string]: string } }.\n` +
`Received: ${typeof entry}${entry !== null ? ` (${JSON.stringify(entry)})` : ''}.\n` +
`Did you forget to convert a number to a string? e.g. params: { id: String(id) }`
)
}
else {
const invalidKeys = Object.keys(entry).filter(
(key) => key !== 'params' && key !== 'locale'
)
Expand Down