Skip to content

Commit

Permalink
fix(types): determine required storage type based on serialize option
Browse files Browse the repository at this point in the history
  • Loading branch information
wodCZ committed Aug 10, 2021
1 parent 56b1c55 commit 996c831
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ export interface PersistentStorage<T> {
removeItem: (key: string) => Promise<T> | Promise<void> | void;
}

export interface ApolloPersistOptions<TSerialized> {
type StorageType<T, TSerialize extends boolean> = TSerialize extends true
? PersistentStorage<string>
: PersistentStorage<T>;

export interface ApolloPersistOptions<
TSerialized,
TSerialize extends boolean = true
> {
cache: ApolloCache<TSerialized>;
storage: PersistentStorage<PersistedData<TSerialized>>;
storage: StorageType<PersistedData<TSerialized>, TSerialize>;
trigger?: 'write' | 'background' | TriggerFunction | false;
debounce?: number;
key?: string;
serialize?: boolean;
serialize?: TSerialize;
maxSize?: number | false;
persistenceMapper?: PersistenceMapperFunction;
debug?: boolean;
Expand Down

0 comments on commit 996c831

Please sign in to comment.