bevacqua / local-storage

:left_luggage: A simplified localStorage API that just works
https://ponyfoo.com
MIT License
523 stars 62 forks source link

Upgrading from 1.4 to 2.0 gives my localstorage.get syntax error with TypeScript #29

Open pkellner opened 4 years ago

pkellner commented 4 years ago

Sorry for not understanding better how to post, but had a working project that just did these two lines:

import ls from 'local-storage';
const user = ls.get('userInfo');

When I upgraded to 2.0, I started getting TypeScrpt error complaining about get.

The error is as follows:

Property 'get' does not exist on type '<T>(key: string, value?: T | undefined) => void'.

If this issue makes no sense, feel free to close. I really don't understand why I'd get an error like that.

sunnyguan commented 3 years ago

Change your import statement to:

import * as ls from "local-storage"

See https://github.com/bevacqua/local-storage#typescript