@@ -37,7 +37,6 @@ const defaults = {
3737
3838export type StoreType = 'cookie' | 'localStorage' | 'memory'
3939
40- type StringKeys < T > = Exclude < keyof T , number | symbol >
4140type StorageObject = Record < string , unknown >
4241
4342class Store {
@@ -217,11 +216,11 @@ export class UniversalStorage<Data extends StorageObject = StorageObject> {
217216 }
218217
219218 /*
220- This is to support few scenarios where:
221- - value exist in one of the stores ( as a result of other stores being cleared from browser ) and we want to resync them
219+ This is to support few scenarios where:
220+ - value exist in one of the stores ( as a result of other stores being cleared from browser ) and we want to resync them
222221 - read values in AJS 1.0 format ( for customers after 1.0 --> 2.0 migration ) and then re-write them in AJS 2.0 format
223222 */
224- public getAndSync < K extends StringKeys < Data > > (
223+ public getAndSync < K extends keyof Data > (
225224 key : K ,
226225 storeTypes ?: StoreType [ ]
227226 ) : Data [ K ] | null {
@@ -235,7 +234,7 @@ export class UniversalStorage<Data extends StorageObject = StorageObject> {
235234 ) as Data [ K ] | null
236235 }
237236
238- public get < K extends StringKeys < Data > > (
237+ public get < K extends keyof Data > (
239238 key : K ,
240239 storeTypes ?: StoreType [ ]
241240 ) : Data [ K ] | null {
@@ -250,7 +249,7 @@ export class UniversalStorage<Data extends StorageObject = StorageObject> {
250249 return null
251250 }
252251
253- public set < K extends StringKeys < Data > > (
252+ public set < K extends keyof Data > (
254253 key : K ,
255254 value : Data [ K ] | null ,
256255 storeTypes ?: StoreType [ ]
@@ -261,10 +260,7 @@ export class UniversalStorage<Data extends StorageObject = StorageObject> {
261260 return value
262261 }
263262
264- public clear < K extends StringKeys < Data > > (
265- key : K ,
266- storeTypes ?: StoreType [ ]
267- ) : void {
263+ public clear < K extends keyof Data > ( key : K , storeTypes ?: StoreType [ ] ) : void {
268264 for ( const store of this . getStores ( storeTypes ) ) {
269265 store . remove ( key )
270266 }
0 commit comments