From 2a0843349c9405c6710d11c75cbbf926afcfb79a Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 19 Feb 2020 00:20:45 -0600 Subject: [PATCH] Update error message for invalid return value from getStaticPaths (#10580) --- 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}` ) }