From fc76a31b7e478878a777b8544be52014a9d0aca7 Mon Sep 17 00:00:00 2001 From: Matthew Gerstman Date: Thu, 8 Sep 2022 17:31:35 -0400 Subject: [PATCH] Improve error when handling a circular dependency --- src/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7a9c920f0..21ec013c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,9 +46,13 @@ function getDependencies(funcs: unknown[]) { ) .join(', ') - throw new Error( - `createSelector expects all input-selectors to be functions, but received the following types: [${dependencyTypes}]` - ) + let error = `createSelector expects all input-selectors to be functions, but received the following types: [${dependencyTypes}].` + if (dependencyTypes.includes('undefined')) { + error += + 'This is likely the result of a circulate dependency in your selector files.' + } + + throw new Error(error) } return dependencies as SelectorArray