mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 13:48:13 +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>
|
default?: () => T | Ref<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CookieRef<T> extends Ref<T> {}
|
export interface CookieRef<T> extends Ref<T | null> {}
|
||||||
|
|
||||||
const CookieDefaults: CookieOptions<any> = {
|
const CookieDefaults: CookieOptions<any> = {
|
||||||
path: '/',
|
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', () => ref('hello'))).toEqualTypeOf<Ref<string>>()
|
||||||
expectTypeOf(useState('test', () => 'hello')).toEqualTypeOf<Ref<string>>()
|
expectTypeOf(useState('test', () => 'hello')).toEqualTypeOf<Ref<string>>()
|
||||||
|
|
||||||
expectTypeOf(useCookie('test', { default: () => ref(500) })).toEqualTypeOf<Ref<number>>()
|
expectTypeOf(useCookie('test', { default: () => ref(500) })).toEqualTypeOf<Ref<number | null>>()
|
||||||
expectTypeOf(useCookie('test', { default: () => 500 })).toEqualTypeOf<Ref<number>>()
|
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: () => ref(500) }).data).toEqualTypeOf<Ref<number | null>>()
|
||||||
expectTypeOf(useAsyncData('test', () => Promise.resolve(500), { default: () => 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