@@ -20,10 +20,10 @@ import { createEvents } from './utils/createEvents'
2020import { filterNoneValueObject , createParams , syncQuery2Conditions , isEquivalent , deepClone } from './utils/common'
2121import { containsProp , isNoData as isDataEmpty , isObject , isServer , rAF } from './utils/helper'
2222
23- export default function useConditionWatcher < O extends object , K extends keyof O > (
24- config : Config < O , K >
25- ) : UseConditionWatcherReturn < O > {
26- function isFetchConfig ( obj : object ) : obj is Config < O , K > {
23+ export default function useConditionWatcher < O extends object , Result = unknown > (
24+ config : Config < O , Result >
25+ ) : UseConditionWatcherReturn < O , Result > {
26+ function isFetchConfig ( obj : object ) : obj is Config < O , Result > {
2727 return containsProp (
2828 obj ,
2929 'fetcher' ,
@@ -50,7 +50,7 @@ export default function useConditionWatcher<O extends object, K extends keyof O>
5050 }
5151
5252 // default config
53- let watcherConfig : Config < O , K > = {
53+ let watcherConfig : Config < O , Result > = {
5454 fetcher : config . fetcher ,
5555 conditions : config . conditions ,
5656 immediate : true ,
@@ -76,7 +76,7 @@ export default function useConditionWatcher<O extends object, K extends keyof O>
7676 const isOnline = ref ( true )
7777 const isActive = ref ( true )
7878
79- const data : ShallowRef = shallowRef (
79+ const data : ShallowRef < Result > = shallowRef (
8080 cache . cached ( backupIntiConditions ) ? cache . get ( backupIntiConditions ) : watcherConfig . initialData || undefined
8181 )
8282 const error = ref ( undefined )
@@ -255,15 +255,15 @@ export default function useConditionWatcher<O extends object, K extends keyof O>
255255 const mutate = ( ...args ) : Mutate => {
256256 const arg = args [ 0 ]
257257 if ( arg === undefined ) {
258- return data . value
258+ return data . value as any
259259 }
260260 if ( typeof arg === 'function' ) {
261261 data . value = arg ( deepClone ( data . value ) )
262262 } else {
263263 data . value = arg
264264 }
265265 cache . set ( { ..._conditions } , data . value )
266- return data . value
266+ return data . value as any
267267 }
268268
269269 // - History mode base on vue-router
0 commit comments