From e8965702e6812c6d0228dd67bbadf3b121d2263b Mon Sep 17 00:00:00 2001 From: Artur Muller Date: Sun, 7 Mar 2021 23:31:46 +0100 Subject: [PATCH] Clarify error message in isSerializableProps --- packages/next/lib/is-serializable-props.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/next/lib/is-serializable-props.ts b/packages/next/lib/is-serializable-props.ts index f09019dab2f911..d9bfcdc7a67853 100644 --- a/packages/next/lib/is-serializable-props.ts +++ b/packages/next/lib/is-serializable-props.ts @@ -1,7 +1,11 @@ const regexpPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/ +function getObjectClassLabel(value: any): string { + return Object.prototype.toString.call(value) +} + function isPlainObject(value: any): boolean { - if (Object.prototype.toString.call(value) !== '[object Object]') { + if (getObjectClassLabel(value) !== '[object Object]') { return false } @@ -19,7 +23,7 @@ export function isSerializableProps( page, method, '', - `Props must be returned as a plain object from ${method}: \`{ props: { ... } }\`.` + `Props must be returned as a plain object from ${method}: \`{ props: { ... } }\` (received: \`${getObjectClassLabel(input)}\`).` ) }