nbubna / store

A better way to use localStorage and sessionStorage
MIT License
1.91k stars 110 forks source link

Incompatible Types using Storage #82

Closed cschroeter closed 4 years ago

cschroeter commented 4 years ago
export function area(id: string, area: Storage): StoreAPI;

should use Web Storage API interface instead of

export interface Storage {
    length: number;
    clear(): void;
    getItem(key: string): string;
    key(index: number): string;
    removeItem(key: string): void;
    setItem(key: string, value: string): void;
}

So

store.area("local", window.localStorage)

does not have this TypeScript error

The types returned by 'getItem(...)' are incompatible between these types.
    Type 'string | null' is not assignable to type 'string'.
      Type 'null' is not assignable to type 'string'.ts(2345)
nbubna commented 4 years ago

Yeah, you're right. I'm crazy busy right now. Are you up for creating a PR or patch to make this quick?

cschroeter commented 4 years ago

@nbubna is there a chance we can craft a release with the new typings? :P

nbubna commented 4 years ago

Yes, sorry. Life a bit nuts, maybe tonight?

On Mon, Aug 3, 2020 at 12:56 AM Christian Schröter notifications@github.com wrote:

@nbubna https://github.com/nbubna is there a chance we can craft a release with the new typings? :P

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nbubna/store/issues/82#issuecomment-667870647, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWW7R2EISLXO7H7SU2CPTR6ZUULANCNFSM4PKKKK4Q .

cschroeter commented 4 years ago

@nbubna if you tell me what to do I also can do a release :)

nbubna commented 4 years ago

I published 2.12.0 this morning. Sorry for the delay! Life's a bit nuts 'round here right now.

On Wed, Aug 12, 2020 at 4:47 AM Christian Schröter notifications@github.com wrote:

@nbubna https://github.com/nbubna if you tell me what to do I also can do a release :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nbubna/store/issues/82#issuecomment-672823185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWW7QXPKKIDIMONIP4TZ3SAJ6OVANCNFSM4PKKKK4Q .

cschroeter commented 4 years ago

@nbubna thanks - I hope things work out for you.