未验证 提交 2a084334 编写于 作者: J JJ Kasper 提交者: GitHub

Update error message for invalid return value from getStaticPaths (#10580)

上级 0a5cc30e
......@@ -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}`
)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册