Skip to content

Commit

Permalink
Change useSwrConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
chibicode committed May 13, 2022
1 parent dfcba4d commit 73e67a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/use-swr-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mergeObjects } from './helper'
import { FullConfiguration, Cache } from '../types'

export const useSWRConfig = <
T extends Cache = Map<string, any>
T extends Cache = Cache
>(): FullConfiguration<T> => {
return mergeObjects(defaultConfig, useContext(SWRConfigContext))
}
3 changes: 1 addition & 2 deletions test/type/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface CustomCache<Data = any> extends Cache<Data> {
}

export function useTestCache() {
expectType<Map<string, any>>(useSWRConfig().cache)
expectType<Map<string, number>>(useSWRConfig<Map<string, number>>().cache)
expectType<Cache>(useSWRConfig().cache)
expectType<CustomCache>(useSWRConfig<CustomCache>().cache)
}

0 comments on commit 73e67a4

Please sign in to comment.