Skip to content

Commit b39ee15

Browse files
remove the unnecessary Partial
1 parent 0078428 commit b39ee15

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ const buildDynamoKey = (key: string) => {
5050
*/
5151
const multiTierCache: IncrementalCache = {
5252
name: "multi-tier-ddb-s3",
53-
async get(key, isFetch) {
53+
async get<IsFetch extends boolean = false>(key: string, isFetch?: IsFetch) {
5454
// First we check the local cache
55-
const localCacheEntry = localCache.get(key);
55+
const localCacheEntry = localCache.get(key) as
56+
| {
57+
value: CacheValue<IsFetch>;
58+
lastModified: number;
59+
}
60+
| undefined;
61+
5662
if (localCacheEntry) {
5763
if (Date.now() - localCacheEntry.lastModified < localCacheTTL) {
5864
debug("Using local cache without checking ddb");

packages/open-next/src/types/overrides.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ export type WithLastModified<T> = {
7575
value?: T;
7676
};
7777

78+
export function isFetchPredicate(value: CacheValue<boolean>): value is CacheValue<true> {
79+
return "kind" in value;
80+
}
81+
7882
export type CacheValue<IsFetch extends boolean> = (IsFetch extends true
79-
? Partial<CachedFetchValue>
83+
? CachedFetchValue
8084
: CachedFile) & { revalidate?: number | false };
8185

8286
export type IncrementalCache = {

0 commit comments

Comments
 (0)