From 14b8708a95d1d166b32f60cb6c8bc1b6ce546a79 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 10 Mar 2021 23:31:52 +0800 Subject: [PATCH] allow passing undefined config (#1022) --- src/use-swr-infinite.ts | 7 +++++-- src/use-swr.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/use-swr-infinite.ts b/src/use-swr-infinite.ts index 0d6e6ed51..999a7a767 100644 --- a/src/use-swr-infinite.ts +++ b/src/use-swr-infinite.ts @@ -22,11 +22,14 @@ function useSWRInfinite( ...args: | readonly [KeyLoader] | readonly [KeyLoader, Fetcher] - | readonly [KeyLoader, SWRInfiniteConfiguration] + | readonly [ + KeyLoader, + SWRInfiniteConfiguration | undefined + ] | readonly [ KeyLoader, Fetcher, - SWRInfiniteConfiguration + SWRInfiniteConfiguration | undefined ] ): SWRInfiniteResponse { const getKey = args[0] diff --git a/src/use-swr.ts b/src/use-swr.ts index 794e96285..4458f5f1b 100644 --- a/src/use-swr.ts +++ b/src/use-swr.ts @@ -210,8 +210,12 @@ function useSWR( ...args: | readonly [Key] | readonly [Key, Fetcher | null] - | readonly [Key, SWRConfiguration] - | readonly [Key, Fetcher | null, SWRConfiguration] + | readonly [Key, SWRConfiguration | undefined] + | readonly [ + Key, + Fetcher | null, + SWRConfiguration | undefined + ] ): SWRResponse { const _key = args[0] const config = Object.assign(