File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ describe('query', () => {
155155 const visibilityMock = mockVisibilityState ( 'hidden' )
156156
157157 let count = 0
158- let result
158+ let result : unknown
159159
160160 const promise = queryClient . fetchQuery ( {
161161 queryKey : key ,
@@ -183,8 +183,10 @@ describe('query', () => {
183183 // Check if the error is set to the cancelled error
184184 try {
185185 await promise
186+ expect . unreachable ( )
186187 } catch {
187188 expect ( isCancelledError ( result ) ) . toBe ( true )
189+ expect ( result instanceof Error ) . toBe ( true )
188190 } finally {
189191 // Reset visibilityState to original value
190192 visibilityMock . mockRestore ( )
Original file line number Diff line number Diff line change @@ -577,19 +577,19 @@ export class Query<
577577 } ) ,
578578 }
579579 case 'error' :
580- const error = action . error as unknown
580+ const error = action . error
581581
582582 if ( isCancelledError ( error ) && error . revert && this . #revertState) {
583583 return { ...this . #revertState, fetchStatus : 'idle' }
584584 }
585585
586586 return {
587587 ...state ,
588- error : error as TError ,
588+ error,
589589 errorUpdateCount : state . errorUpdateCount + 1 ,
590590 errorUpdatedAt : Date . now ( ) ,
591591 fetchFailureCount : state . fetchFailureCount + 1 ,
592- fetchFailureReason : error as TError ,
592+ fetchFailureReason : error ,
593593 fetchStatus : 'idle' ,
594594 status : 'error' ,
595595 }
Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ export function canFetch(networkMode: NetworkMode | undefined): boolean {
5454 : true
5555}
5656
57- export class CancelledError {
57+ export class CancelledError extends Error {
5858 revert ?: boolean
5959 silent ?: boolean
6060 constructor ( options ?: CancelOptions ) {
61+ super ( 'CancelledError' )
6162 this . revert = options ?. revert
6263 this . silent = options ?. silent
6364 }
Original file line number Diff line number Diff line change @@ -100,9 +100,6 @@ export function useBaseQuery<
100100
101101 // Handle suspense
102102 if ( shouldSuspend ( defaultedOptions , result ) ) {
103- // Do the same thing as the effect right above because the effect won't run
104- // when we suspend but also, the component won't re-mount so our observer would
105- // be out of date.
106103 throw fetchOptimistic ( defaultedOptions , observer , errorResetBoundary )
107104 }
108105
You can’t perform that action at this time.
0 commit comments