cmp-cc / vue-cookies

A simple Vue.js plugin for handling browser cookies
MIT License
408 stars 70 forks source link

TS2532: Object is possibly 'undefined' with TypeScript #94

Open igorfraa opened 1 year ago

igorfraa commented 1 year ago

Hello, I use vue-cookies TypeScript and analyser says that injected cookies could be undefined.

const cookies = inject<VueCookies>('$cookies')
cookies.set('my_cookie', btoa(cookieVal))

The warning got easily suppressed with optional chaining (cookies?.set()), but it look a little weird due const not assumed to be undefined any way.