microcipcip / cookie-universal

Universal cookie plugin, perfect for SSR
525 stars 39 forks source link

Update index.d.ts to be able to type the return of the getters functions #65

Closed amoutonbrady closed 4 years ago

amoutonbrady commented 4 years ago

Hey, I did not see any contributor guideline or anything. Hopefully, I'm doing things right.

I'd like to propose a small QOL change. To be able to type the return of a $cookie.get & $cookie.getAll which would default to any if not set.

Therefore this would be possible:

this.$cookie.set('hello', 'world');

const value = this.$cookie.get<string>('hello');
// value will be typed as a string instead of any;
microcipcip commented 4 years ago

Hi @amoutonbrady, thanks for contributing. It looks like a nice addition to the library, I'll merge it when I have some free time.

microcipcip commented 4 years ago

@amoutonbrady your PR is now merged and you can use it with version 2.1.4.