Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): allow cookies to be set to null to unset them (#8769)
Browse files Browse the repository at this point in the history
Co-authored-by: Magyar Balázs <magyarb94@gmail.com>
  • Loading branch information
danielroe and magyarb committed Nov 9, 2022
1 parent 1582f8e commit e76ebdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/cookie.ts
Expand Up @@ -15,7 +15,7 @@ export interface CookieOptions<T = any> extends _CookieOptions {
default?: () => T | Ref<T>
}

export interface CookieRef<T> extends Ref<T> {}
export interface CookieRef<T> extends Ref<T | null> {}

const CookieDefaults: CookieOptions<any> = {
path: '/',
Expand Down
5 changes: 3 additions & 2 deletions test/fixtures/basic/types.ts
Expand Up @@ -154,8 +154,9 @@ describe('composables', () => {
expectTypeOf(useState('test', () => ref('hello'))).toEqualTypeOf<Ref<string>>()
expectTypeOf(useState('test', () => 'hello')).toEqualTypeOf<Ref<string>>()

expectTypeOf(useCookie('test', { default: () => ref(500) })).toEqualTypeOf<Ref<number>>()
expectTypeOf(useCookie('test', { default: () => 500 })).toEqualTypeOf<Ref<number>>()
expectTypeOf(useCookie('test', { default: () => ref(500) })).toEqualTypeOf<Ref<number | null>>()
expectTypeOf(useCookie('test', { default: () => 500 })).toEqualTypeOf<Ref<number | null>>()
useCookie('test').value = null

expectTypeOf(useAsyncData('test', () => Promise.resolve(500), { default: () => ref(500) }).data).toEqualTypeOf<Ref<number | null>>()
expectTypeOf(useAsyncData('test', () => Promise.resolve(500), { default: () => 500 }).data).toEqualTypeOf<Ref<number | null>>()
Expand Down

0 comments on commit e76ebdd

Please sign in to comment.