From f8825322b667e997d40c07a7d7dde63ab2b438b7 Mon Sep 17 00:00:00 2001 From: Weston Catron Date: Thu, 24 Aug 2023 18:07:17 -0400 Subject: [PATCH] fix: remove permissive type --- _internal/src/types.ts | 8 ++++---- test/type/fetcher.ts | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) 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)