Skip to content

Commit

Permalink
fix type for withCache (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardlyhel committed Sep 25, 2023
1 parent 425791c commit 1be1e40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-steaks-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

Allow generic inference in standalone usage of WithCache type - Contributed by @chinanderm
6 changes: 3 additions & 3 deletions packages/hydrogen/src/with-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export function createWithCache<T = unknown>(
*
* Use the `CachingStrategy` to define a custom caching mechanism for your data. Or use one of the built-in caching strategies: `CacheNone`, `CacheShort`, `CacheLong`.
*/
type CreateWithCacheReturn<T> = (
type CreateWithCacheReturn<T> = <U = T>(
cacheKey: CacheKey,
strategy: CachingStrategy,
actionFn: () => T | Promise<T>,
) => Promise<T>;
actionFn: () => U | Promise<U>,
) => Promise<U>;

export type WithCache = ReturnType<typeof createWithCache>;

0 comments on commit 1be1e40

Please sign in to comment.