From bf787a31b314a7811cd5351ea89b47ddfa34b6a6 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 18 Feb 2020 16:32:15 -0600 Subject: [PATCH] Update error message for invalid return value from getStaticPaths --- packages/next/build/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 5f76e1d087b97b5..8d6aeeb096d3376 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -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}` ) } @@ -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}` ) }