vue-universal-cookies icon indicating copy to clipboard operation
vue-universal-cookies copied to clipboard

TS2339: Property '$cookies' does not exist on type (ambient Typescript declarations not in dist)

Open frankier opened this issue 6 years ago • 4 comments

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.

frankier avatar Mar 13 '18 09:03 frankier

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 :)

jjoshi-space avatar Oct 12 '18 11:10 jjoshi-space

In my nuxt project worked by adding in tsconfig.json "types": [ ... "cookie-universal-nuxt", ]

ghost avatar Dec 15 '20 16:12 ghost

"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'));

RyaiStudio avatar Oct 22 '21 10:10 RyaiStudio

In my nuxt project worked by adding in tsconfig.json "types": [ ... "cookie-universal-nuxt", ]

Exactly what I was looking for, thanks a lot!

OmarAbdo avatar Feb 19 '22 19:02 OmarAbdo