From 8d174c8f92fd7cc357231f9a33d5c33604b9905d Mon Sep 17 00:00:00 2001 From: Neef Rehman Date: Mon, 13 Jan 2025 13:18:23 +0000 Subject: [PATCH] fix(types): support both `Array` and `ReadonlyArray` for typed query and mutation keys (#8529) * fix(types): support both `Array` and `ReadonlyArray` for typed query and mutation keys * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- packages/query-core/src/types.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/query-core/src/types.ts b/packages/query-core/src/types.ts index 5014cfbf1f..26d978b8ee 100644 --- a/packages/query-core/src/types.ts +++ b/packages/query-core/src/types.ts @@ -45,9 +45,11 @@ export type DefaultError = Register extends { export type QueryKey = Register extends { queryKey: infer TQueryKey } - ? TQueryKey extends Array + ? TQueryKey extends ReadonlyArray ? TQueryKey - : ReadonlyArray + : TQueryKey extends Array + ? TQueryKey + : ReadonlyArray : ReadonlyArray export const dataTagSymbol = Symbol('dataTagSymbol') @@ -1009,7 +1011,9 @@ export type MutationKey = Register extends { } ? TMutationKey extends Array ? TMutationKey - : ReadonlyArray + : TMutationKey extends Array + ? TMutationKey + : ReadonlyArray : ReadonlyArray export type MutationStatus = 'idle' | 'pending' | 'success' | 'error'