Moved SwrOptions type

This commit is contained in:
Luis Alvarez 2021-02-08 18:13:29 -05:00
parent 82c5cd4aba
commit 7f3174bcd0
2 changed files with 11 additions and 16 deletions

View File

@ -1,4 +1,6 @@
import type { ResponseState, SwrOptions } from './use-data'
import type { ConfigInterface } from 'swr'
import type { CommerceError } from './errors'
import type { ResponseState } from './use-data'
export type Override<T, K> = Omit<T, keyof K> & K
@ -67,3 +69,9 @@ export type HookHandler<
fetcher?: HookFetcherFn<Data, FetchInput, Result, Body>
normalizer?(data: Result): Data
}
export type SwrOptions<Data, Input = null, Result = any> = ConfigInterface<
Data,
CommerceError,
HookFetcher<Data, Input, Result>
>

View File

@ -1,20 +1,7 @@
import useSWR, { ConfigInterface, responseInterface } from 'swr'
import type {
HookHandler,
HookInput,
HookFetcher,
PickRequired,
Fetcher,
} from './types'
import useSWR, { responseInterface } from 'swr'
import type { HookHandler, HookInput, PickRequired, Fetcher } from './types'
import defineProperty from './define-property'
import { CommerceError } from './errors'
import { useCommerce } from '..'
export type SwrOptions<Data, Input = null, Result = any> = ConfigInterface<
Data,
CommerceError,
HookFetcher<Data, Input, Result>
>
export type ResponseState<Result> = responseInterface<Result, CommerceError> & {
isLoading: boolean