Skip to content

Commit

Permalink
fix: remove permissive type (#2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcatron committed Sep 10, 2023
1 parent 4d20bff commit 141cccf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions _internal/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ export interface SWRHook {
key: SWRKey,
fetcher: Fetcher<Data, SWRKey> | null
): SWRResponse<Data, Error>
<Data = any, Error = any, SWRKey extends Key = Key>(
key: SWRKey,
fetcher: Fetcher<Data, SWRKey> | null
): SWRResponse<Data, Error>
<
Data = any,
Error = any,
Expand Down Expand Up @@ -259,10 +263,6 @@ export interface SWRHook {
config: SWROptions
): SWRResponse<Data, Error, SWROptions>
<Data = any, Error = any>(key: Key): SWRResponse<Data, Error>
<Data = any, Error = any>(
key: Key,
fetcher: BareFetcher<Data> | null
): SWRResponse<Data, Error>
<
Data = any,
Error = any,
Expand Down
2 changes: 2 additions & 0 deletions test/type/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type { Equal } from '@type-challenges/utils'
export function useDataErrorGeneric() {
useSWR<{ id: number }>('/api/', () => ({ id: 123 }))
useSWR<string, any>('/api/', (key: string) => key)
const fetcher = ({ url }: { url: string }) => url
useSWR({ url: '/api' }, fetcher)
useSWRInfinite<string[], any>(
(index, previousPageData) => {
expectType<Equal<number, typeof index>>(true)
Expand Down

0 comments on commit 141cccf

Please sign in to comment.