diff --git a/package.json b/package.json index 601665b..f9c82bd 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "vitest": "^1.4.0" }, "peerDependencies": { - "next": "^12.0.0 || ^13.0.0 || ^14.0.0", + "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", "react": "^16.0.0 || ^17.0.0 || ^18.0.0", "react-router-dom": "^6.0.0", "zod": "^3.0.0" diff --git a/src/engine/query.ts b/src/engine/query.ts index 3958bcf..5897f67 100644 --- a/src/engine/query.ts +++ b/src/engine/query.ts @@ -2,17 +2,7 @@ import { useCallback, useMemo } from 'react' export type Query = Record -export type AbstractQueryValueElement = - | string - | number - | boolean - | Date - | bigint - -export type AbstractQuery = Record< - string, - AbstractQueryValueElement | AbstractQueryValueElement[] -> +export type AbstractQuery = Record /** * Parses the query. @@ -59,7 +49,7 @@ export type AbstractQueryOptions = { /** * How the abstract query is converted to an actual query. * - * @default Each value that is not undefined is converted to a string by calling `.toString()`. + * @default Each value that is not undefined is converted to a string by calling `.toString()` or removed if not stringifyable. */ convertToQuery: (abstractQuery: Partial) => Query } @@ -69,10 +59,19 @@ const DEFAULT_ABSTRACT_QUERY_OPTIONS: AbstractQueryOptions = { const query: Query = {} for (const [key, value] of Object.entries(abstractQuery)) { if (Array.isArray(value)) { - query[key] = value.map((v) => v.toString()) + query[key] = value.map((v: unknown) => + typeof v?.toString === 'function' + ? // eslint-disable-next-line @typescript-eslint/no-base-to-string + v.toString() + : '', + ) } else { if (value !== undefined) { - query[key] = value.toString() + query[key] = + typeof value?.toString === 'function' + ? // eslint-disable-next-line @typescript-eslint/no-base-to-string + value.toString() + : '' } } }