arve0 / vue-persistent-state

Persist state to localstorage
https://www.npmjs.com/package/vue-persistent-state
11 stars 1 forks source link

Typescript? #5

Closed Dan-True closed 6 years ago

Dan-True commented 6 years ago

Hi.

I can import this in typescript by making my own module definition, but I can't see any way to access $store or the property in my components?

arve0 commented 6 years ago

Assuming by "I can't see any way to access $store or the property in my components", means that the autocomplete/type-hints are not working. (+ maybe the compiler warns/errors?). Please be more specific if this is not the case.

To why TypeScript is unable to detect .$store, it is set dynamically:

https://github.com/arve0/vue-persistent-state/blob/78ba43db39e15cc153f08fcad1818fbbff132db7/index.js#L23

I believe TypeScript does not detect this? Anyway, you probably need to give TypeScript some hint with a .d.ts file.