Uh oh!
There was an error while loading. Please reload this page.
fix(nuxt): allow cookies to be set to null to unset them - #8769
Conversation
### Discussed in https://github.com/nuxt/framework/discussions/2576 The cookie.value is typed as string, so // @ts-ignore must be used to do this. I have fixed the types, so the cookie can be deleted without a ts error.
|
✅ Deploy Preview for nuxt3-docs canceled.
|
null to unset themAareksio
commented
Nov 21, 2022
@danielroe This caused |
danielroe
commented
Nov 21, 2022
@Aareksio I appreciate it; the issue is that it can be null if you set it to null. You could cast it |
After this change, all code must be explicitly null-checked or constlanguages=useCookie<string[]>('languages',{default: ()=>['en']})asRef<string[]>// orfor(constlanguageof(languagesasRef<string[]>).value){}I understand the reasoning on why the change was made. It just seems to break more (important) use-cases than it fixes. |
danielroe
commented
Nov 21, 2022
I wonder if we could allow overriding with generic - so by default it infers a type with null, but you can override by setting your own value? And if you need to delete you can add |
Before the change, you should be able to do https://github.com/nuxt/framework/blob/main/packages/nuxt/src/app/composables/cookie.ts#L26 |
❓ Type of change
📚 Description
remake of #8754
📝 Checklist