Skip to content

Commit

Permalink
fix(types): loosen wrapper type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
wodCZ committed Aug 1, 2021
1 parent 15d8b40 commit ecb0a41
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/storageWrappers/AsyncStorageWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ import { PersistentStorage } from '../types';
* });
*
*/
export class AsyncStorageWrapper implements PersistentStorage<string> {
export class AsyncStorageWrapper implements PersistentStorage<any> {
// Actual type definition: https://github.com/react-native-async-storage/async-storage/blob/master/types/index.d.ts
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> {
setItem(key: string, value: any): void | Promise<void> {
return this.storage.setItem(key, value);
}
}
6 changes: 3 additions & 3 deletions src/storageWrappers/IonicStorageWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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> {
setItem(key: string, value: any): void | Promise<void> {
return this.storage.set(key, value);
}
}
6 changes: 3 additions & 3 deletions src/storageWrappers/LocalForageWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { PersistentStorage } from '../types';

export class LocalForageWrapper implements PersistentStorage<string | object> {
export class LocalForageWrapper implements PersistentStorage<any> {
// Actual type definition: https://github.com/localForage/localForage/blob/master/typings/localforage.d.ts#L17
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> {
setItem(key: string, value: any): void | Promise<void> {
return new Promise((resolve, reject) => {
this.storage
.setItem(key, value)
Expand Down
6 changes: 3 additions & 3 deletions src/storageWrappers/LocalStorageWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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> {
setItem(key: string, value: any): void | Promise<void> {
return this.storage.setItem(key, value);
}
}
6 changes: 3 additions & 3 deletions src/storageWrappers/MMKVStorageWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { PersistentStorage } from '../types';
* });
*
*/
export class MMKVStorageWrapper implements PersistentStorage<string> {
export class MMKVStorageWrapper implements PersistentStorage<any> {
// Actual type definition: https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/index.d.ts#L27
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);
}

Expand All @@ -32,7 +32,7 @@ export class MMKVStorageWrapper implements PersistentStorage<string> {
});
}

setItem(key: string, value: string): void | Promise<void> {
setItem(key: string, value: any): void | Promise<void> {
return new Promise((resolve, reject) => {
this.storage
.setItem(key, value)
Expand Down
6 changes: 3 additions & 3 deletions src/storageWrappers/SessionStorageWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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> {
setItem(key: string, value: any): void | Promise<void> {
return this.storage.setItem(key, value);
}
}

0 comments on commit ecb0a41

Please sign in to comment.