Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove permissive type #2759

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading