forked from apollographql/apollo-cache-persist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): loosen wrapper type definitions
- Loading branch information
Showing
6 changed files
with
33 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { PersistentStorage } from '../types'; | ||
|
||
export class IonicStorageWrapper implements PersistentStorage<string> { | ||
export class IonicStorageWrapper implements PersistentStorage<any> { | ||
// Actual type definition: https://github.com/ionic-team/ionic-storage/blob/main/src/storage.ts#L102 | ||
private storage; | ||
|
||
constructor(storage: any) { | ||
this.storage = storage; | ||
} | ||
|
||
getItem(key: string): string | Promise<string | null> | null { | ||
getItem(key: string): any | Promise<any> | null { | ||
return this.storage.get(key); | ||
} | ||
|
||
removeItem(key: string): void | Promise<void> { | ||
return this.storage.remove(key); | ||
} | ||
|
||
setItem(key: string, value: string): void | Promise<void> { | ||
return this.storage.set(key, value); | ||
setItem(key: string, value: any): void | Promise<void> { | ||
return this.storage.set( | ||
key, | ||
typeof value === 'string' ? value : value.toString(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { PersistentStorage } from '../types'; | ||
|
||
export class LocalStorageWrapper implements PersistentStorage<string> { | ||
export class LocalStorageWrapper implements PersistentStorage<any> { | ||
// Actual type definition: https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L15286 | ||
private storage; | ||
|
||
constructor(storage: any) { | ||
this.storage = storage; | ||
} | ||
|
||
getItem(key: string): string | Promise<string | null> | null { | ||
getItem(key: string): any | Promise<any> | null { | ||
return this.storage.getItem(key); | ||
} | ||
|
||
removeItem(key: string): void | Promise<void> { | ||
return this.storage.removeItem(key); | ||
} | ||
|
||
setItem(key: string, value: string): void | Promise<void> { | ||
return this.storage.setItem(key, value); | ||
setItem(key: string, value: any): void | Promise<void> { | ||
return this.storage.setItem( | ||
key, | ||
typeof value === 'string' ? value : value.toString(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { PersistentStorage } from '../types'; | ||
|
||
export class SessionStorageWrapper implements PersistentStorage<string> { | ||
export class SessionStorageWrapper implements PersistentStorage<any> { | ||
// Actual type definition: https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L15286 | ||
private storage; | ||
|
||
constructor(storage: any) { | ||
this.storage = storage; | ||
} | ||
|
||
getItem(key: string): string | Promise<string | null> | null { | ||
getItem(key: string): any | Promise<any> | null { | ||
return this.storage.getItem(key); | ||
} | ||
|
||
removeItem(key: string): void | Promise<void> { | ||
return this.storage.removeItem(key); | ||
} | ||
|
||
setItem(key: string, value: string): void | Promise<void> { | ||
return this.storage.setItem(key, value); | ||
setItem(key: string, value: any): void | Promise<void> { | ||
return this.storage.setItem( | ||
key, | ||
typeof value === 'string' ? value : value.toString(), | ||
); | ||
} | ||
} |