Skip to content

Commit 611b1c8

Browse files
committed
fix types for cache functions with all optional arguments
1 parent e773947 commit 611b1c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/data/cache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export function cacheKeyOp(key: string | string[] | void, fn: (cacheEntry: Cache
5555
export type CachedFunction<T extends (...args: any) => any> = T extends (
5656
...args: infer A
5757
) => infer R
58-
? ([] extends A ? (...args: never[]) => R : T) & {
58+
? ([] extends { [K in keyof A]-?: A[K] } // A tuple full of optional values is equivalent to an empty tuple
59+
? (...args: never[]) => R
60+
: T) & {
5961
keyFor: (...args: A) => string;
6062
key: string;
6163
}

0 commit comments

Comments
 (0)