Skip to content

Commit 1f5bdb4

Browse files
authored
Merge pull request #392 from Brendonovich/main
Fix types for cache functions with all optional arguments
2 parents e773947 + 94797e1 commit 1f5bdb4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/nervous-rockets-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
Fix types for cache functions with all optional arguments

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)