diff --git a/_internal/src/types.ts b/_internal/src/types.ts index e0215a7b5..9f40438cf 100644 --- a/_internal/src/types.ts +++ b/_internal/src/types.ts @@ -231,6 +231,10 @@ export interface SWRHook { key: SWRKey, fetcher: Fetcher | null ): SWRResponse + ( + key: SWRKey, + fetcher: Fetcher | null + ): SWRResponse < Data = any, Error = any, @@ -259,10 +263,6 @@ export interface SWRHook { config: SWROptions ): SWRResponse (key: Key): SWRResponse - ( - key: Key, - fetcher: BareFetcher | null - ): SWRResponse < Data = any, Error = any, diff --git a/test/type/fetcher.ts b/test/type/fetcher.ts index 697d99daf..3a476aa04 100644 --- a/test/type/fetcher.ts +++ b/test/type/fetcher.ts @@ -6,6 +6,8 @@ import type { Equal } from '@type-challenges/utils' export function useDataErrorGeneric() { useSWR<{ id: number }>('/api/', () => ({ id: 123 })) useSWR('/api/', (key: string) => key) + const fetcher = ({ url }: { url: string }) => url + useSWR({ url: '/api' }, fetcher) useSWRInfinite( (index, previousPageData) => { expectType>(true)