-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 them
@danielroe This caused |
@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 const languages = useCookie<string[]>('languages', { default: () => ['en'] }) as Ref<string[]>
// or
for (const language of (languages as Ref<string[]>).value) {} I understand the reasoning on why the change was made. It just seems to break more (important) use-cases than it fixes. |
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