Skip to content

Commit 996c831

Browse files
committed
fix(types): determine required storage type based on serialize option
1 parent 56b1c55 commit 996c831

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/types/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ export interface PersistentStorage<T> {
1818
removeItem: (key: string) => Promise<T> | Promise<void> | void;
1919
}
2020

21-
export interface ApolloPersistOptions<TSerialized> {
21+
type StorageType<T, TSerialize extends boolean> = TSerialize extends true
22+
? PersistentStorage<string>
23+
: PersistentStorage<T>;
24+
25+
export interface ApolloPersistOptions<
26+
TSerialized,
27+
TSerialize extends boolean = true
28+
> {
2229
cache: ApolloCache<TSerialized>;
23-
storage: PersistentStorage<PersistedData<TSerialized>>;
30+
storage: StorageType<PersistedData<TSerialized>, TSerialize>;
2431
trigger?: 'write' | 'background' | TriggerFunction | false;
2532
debounce?: number;
2633
key?: string;
27-
serialize?: boolean;
34+
serialize?: TSerialize;
2835
maxSize?: number | false;
2936
persistenceMapper?: PersistenceMapperFunction;
3037
debug?: boolean;

0 commit comments

Comments
 (0)