mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): allow cookies to be set to null
to unset them (#8769)
Co-authored-by: Magyar Balázs <magyarb94@gmail.com>
This commit is contained in:
parent
1582f8ec01
commit
e76ebdddd0
@ -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: '/',
|
||||
|
5
test/fixtures/basic/types.ts
vendored
5
test/fixtures/basic/types.ts
vendored
@ -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>>()
|
||||
|
Loading…
Reference in New Issue
Block a user