@@ -10,34 +10,24 @@ export type Fetcher<Data = unknown, Args extends Key = Key> =
10
10
*/
11
11
Args extends ( ( ) => readonly [ ...infer K ] | null )
12
12
? ( ( ...args : [ ...K ] ) => Result < Data > )
13
- /**
14
- * [{ foo: string }, { bar: number } ] | null
15
- *
16
- * [{ foo: string }, { bar: number } ] as const | null
17
- */
18
- : Args extends ( readonly [ ...infer K ] )
13
+ : /**
14
+ * [{ foo: string }, { bar: number } ] | null
15
+ *
16
+ * [{ foo: string }, { bar: number } ] as const | null
17
+ */
18
+ Args extends ( readonly [ ...infer K ] )
19
19
? ( ( ...args : [ ...K ] ) => Result < Data > )
20
- /**
21
- * () => string | null
22
- * () => Record<any, any> | null
23
- */
24
- : Args extends ( ( ) => infer T | null )
20
+ : /**
21
+ * () => string | null
22
+ * () => Record<any, any> | null
23
+ */
24
+ Args extends ( ( ) => infer T | null )
25
25
? ( ...args : [ T ] ) => Result < Data >
26
- /**
27
- * string | null
28
- */
29
- : Args extends ( string | null )
30
- /**
31
- * when key is Record<any, any> | null
32
- * use { foo: string, bar: number } | null as example
33
- *
34
- * the fetcher would be
35
- * (arg0: string) => any | (arg0: { foo: string, bar: number }) => any
36
- * so we add this condition to make (arg0: string) => any to be never
37
- */
38
- ? Args extends ( Record < any , any > | null )
39
- ? never
40
- : ( ...args : [ string ] ) => Result < Data >
26
+ : /**
27
+ * string | null | Record<any,any>
28
+ */
29
+ Args extends null
30
+ ? never
41
31
: Args extends ( infer T )
42
32
? ( ...args : [ T ] ) => Result < Data >
43
33
: never
0 commit comments