Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
promer94 committed Mar 8, 2021
2 parents f95a338 + 9f37400 commit 7afea20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
12 changes: 4 additions & 8 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { dequal } from 'dequal/lite'
import {
ConfigInterface,
RevalidateOptionInterface,
revalidateType
} from './types'
import { Configuration, RevalidatorOptions, Revalidator } from './types'
import Cache from './cache'
import webPreset from './libs/web-preset'

Expand All @@ -14,9 +10,9 @@ const cache = new Cache()
function onErrorRetry(
_: unknown,
__: string,
config: Readonly<Required<ConfigInterface>>,
revalidate: revalidateType,
opts: Required<RevalidateOptionInterface>
config: Readonly<Required<Configuration>>,
revalidate: Revalidator,
opts: Required<RevalidatorOptions>
): void {
if (!config.isDocumentVisible()) {
// if it's hidden, stop
Expand Down
4 changes: 2 additions & 2 deletions src/swr-config-context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext } from 'react'

import { ConfigInterface } from './types'
import { SWRConfiguration } from './types'

const SWRConfigContext = createContext<Partial<ConfigInterface>>({})
const SWRConfigContext = createContext<SWRConfiguration>({})
SWRConfigContext.displayName = 'SWRConfigContext'

export default SWRConfigContext
15 changes: 4 additions & 11 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export interface Configuration<
revalidateOnMount?: boolean
revalidateOnReconnect: boolean
shouldRetryOnError: boolean
fetcher: Fn
suspense: boolean
fetcher: Fn
initialData?: Data

isOnline: () => boolean
Expand Down Expand Up @@ -50,11 +50,6 @@ export interface Configuration<
compare: (a: Data | undefined, b: Data | undefined) => boolean
}

export interface RevalidateOptionInterface {
retryCount?: number
dedupe?: boolean
}

export type ValueKey = string | any[] | null

export type Updater<Data = any, Error = any> = (
Expand Down Expand Up @@ -125,7 +120,7 @@ export type responseInterface<Data, Error> = {
) => Promise<Data | undefined>
isValidating: boolean
}
export type SWRResponse<Data, Error> = {
export interface SWRResponse<Data, Error> {
data?: Data
error?: Error
revalidate: () => Promise<boolean>
Expand Down Expand Up @@ -168,10 +163,8 @@ export type SWRInfiniteResponseInterface<Data = any, Error = any> = SWRResponse<
size: number | ((size: number) => number)
) => Promise<Data[] | undefined>
}
export type SWRInfiniteResponse<Data = any, Error = any> = SWRResponse<
Data[],
Error
> & {
export interface SWRInfiniteResponse<Data = any, Error = any>
extends SWRResponse<Data[], Error> {
size: number
setSize: (
size: number | ((size: number) => number)
Expand Down
4 changes: 2 additions & 2 deletions src/use-swr-infinite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function useSWRInfinite<Data = any, Error = any>(
...args:
| readonly [KeyLoader<Data>]
| readonly [KeyLoader<Data>, Fetcher<Data>]
| readonly [KeyLoader<Data>, Partial<SWRInfiniteConfiguration<Data, Error>>]
| readonly [KeyLoader<Data>, SWRInfiniteConfiguration<Data, Error>]
| readonly [
KeyLoader<Data>,
Fetcher<Data>,
Partial<SWRInfiniteConfiguration<Data, Error>>
SWRInfiniteConfiguration<Data, Error>
]
): SWRInfiniteResponse<Data, Error> {
const getKey = args[0]
Expand Down

0 comments on commit 7afea20

Please sign in to comment.