Skip to content

Commit

Permalink
test: add typing test for empty config (#2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Mar 22, 2023
1 parent 1af69c9 commit 5eceb29
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/type/config.tsx
Expand Up @@ -137,3 +137,15 @@ export function testConfigAsSWRConfiguration() {
const { data } = useSWR('/api', fetcher, {} as SWRConfiguration)
expectType<Equal<typeof data, { value: string } | undefined>>(true)
}

export function testEmptyConfig() {
const fetcher = (k: string) => Promise.resolve({ value: k })
const { data, error, isLoading } = useSWR<{ value: string }, Error>(
'/api',
fetcher,
{}
)
expectType<Equal<typeof data, { value: string } | undefined>>(true)
expectType<Equal<typeof error, Error | undefined>>(true)
expectType<Equal<typeof isLoading, boolean>>(true)
}

0 comments on commit 5eceb29

Please sign in to comment.