vue-universal-cookies
vue-universal-cookies copied to clipboard
TS2339: Property '$cookies' does not exist on type (ambient Typescript declarations not in dist)
If you use this in a typescript Vue component, e.g.
this.$cookies.set('foo', resp, {
secure: true
});
You will get an error like this:
TS2339: Property '$cookies' does not exist on type
The underlying problem is the contents of https://github.com/S64/vue-universal-cookies/blob/master/packages/vue-universal-cookies/typings/vue.d.ts are not included in dist/index.d.ts . I haven't been able to find a way to get these ambient declarations included in index.d.ts.
My current workaround is to write:
import 'vue-universal-cookies/typings/vue'
in my component.
Stuck on the same issue. If you do find the solution then please help me out with , on https://stackoverflow.com/questions/52775027/vue-compiler-unable-to-parse-cookies Thank you :)
In my nuxt project worked by adding in tsconfig.json
"types": [ ... "cookie-universal-nuxt", ]
"types": [ ... "cookie-universal-nuxt", ]
adding in tsconfig.json
I just figure something hope this helps
const { $cookiz }:any = this
console.log($cookiz.get('storeAddress'));
const { $cookiz }:any = this.$root.$options
console.log($cookiz.get('storeAddress'));
In my nuxt project worked by adding in tsconfig.json
"types": [ ... "cookie-universal-nuxt", ]
Exactly what I was looking for, thanks a lot!