Skip to content

Commit

Permalink
Merge branch 'main' into Fix_syntax_error_in_Equal_type_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-nanayakkara authored Mar 23, 2023
2 parents a764797 + 5eceb29 commit a8b2473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swr",
"version": "2.1.0",
"version": "2.1.1",
"description": "React Hooks library for remote data fetching",
"keywords": [
"swr",
Expand Down
12 changes: 12 additions & 0 deletions test/type/config.tsx
Original file line number Diff line number Diff line change
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 a8b2473

Please sign in to comment.