Skip to content

Commit

Permalink
fix(types): support both Array and ReadonlyArray for typed query …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
neefrehman and autofix-ci[bot] authored Jan 13, 2025
1 parent 4a589bf commit 8d174c8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export type DefaultError = Register extends {
export type QueryKey = Register extends {
queryKey: infer TQueryKey
}
? TQueryKey extends Array<unknown>
? TQueryKey extends ReadonlyArray<unknown>
? TQueryKey
: ReadonlyArray<unknown>
: TQueryKey extends Array<unknown>
? TQueryKey
: ReadonlyArray<unknown>
: ReadonlyArray<unknown>

export const dataTagSymbol = Symbol('dataTagSymbol')
Expand Down Expand Up @@ -1009,7 +1011,9 @@ export type MutationKey = Register extends {
}
? TMutationKey extends Array<unknown>
? TMutationKey
: ReadonlyArray<unknown>
: TMutationKey extends Array<unknown>
? TMutationKey
: ReadonlyArray<unknown>
: ReadonlyArray<unknown>

export type MutationStatus = 'idle' | 'pending' | 'success' | 'error'
Expand Down

0 comments on commit 8d174c8

Please sign in to comment.