Skip to content

Commit

Permalink
Update error message for invalid return value from getStaticPaths (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 19, 2020
1 parent 0a5cc30 commit 2a08433
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/next/build/utils.ts
Expand Up @@ -562,9 +562,15 @@ export async function isPageStatic(

const staticPathsResult = await (mod.unstable_getStaticPaths as Unstable_getStaticPaths)()

if (!staticPathsResult || typeof staticPathsResult !== 'object') {
const expectedReturnVal = `Expected: { paths: [] }`

if (
!staticPathsResult ||
typeof staticPathsResult !== 'object' ||
Array.isArray(staticPathsResult)
) {
throw new Error(
`Invalid value returned from unstable_getStaticPaths in ${page}. Received ${typeof staticPathsResult} Expected: { paths: [] }`
`Invalid value returned from unstable_getStaticPaths in ${page}. Received ${typeof staticPathsResult} ${expectedReturnVal}`
)
}

Expand All @@ -576,7 +582,7 @@ export async function isPageStatic(
throw new Error(
`Extra keys returned from unstable_getStaticPaths in ${page} (${invalidStaticPathKeys.join(
', '
)}) The only field allowed currently is \`paths\``
)}) ${expectedReturnVal}`
)
}

Expand Down

0 comments on commit 2a08433

Please sign in to comment.