Skip to content

Commit 5eceb29

Browse files
authored
test: add typing test for empty config (#2521)
1 parent 1af69c9 commit 5eceb29

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/type/config.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,15 @@ export function testConfigAsSWRConfiguration() {
137137
const { data } = useSWR('/api', fetcher, {} as SWRConfiguration)
138138
expectType<Equal<typeof data, { value: string } | undefined>>(true)
139139
}
140+
141+
export function testEmptyConfig() {
142+
const fetcher = (k: string) => Promise.resolve({ value: k })
143+
const { data, error, isLoading } = useSWR<{ value: string }, Error>(
144+
'/api',
145+
fetcher,
146+
{}
147+
)
148+
expectType<Equal<typeof data, { value: string } | undefined>>(true)
149+
expectType<Equal<typeof error, Error | undefined>>(true)
150+
expectType<Equal<typeof isLoading, boolean>>(true)
151+
}

0 commit comments

Comments
 (0)