From 9d1ca7cd88651de1fe196beb11251f186d8288b1 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sat, 20 Jan 2024 00:50:16 +0100 Subject: [PATCH] fix(nuxt): deprecate boolean values for `dedupe` (#25334) --- packages/nuxt/src/app/composables/asyncData.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 71a236a28c..de13125034 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -92,7 +92,7 @@ export interface AsyncDataOptions< export interface AsyncDataExecuteOptions { _initial?: boolean - // TODO: deprecate boolean option in future minor + // TODO: remove boolean option in Nuxt 4 /** * Force a refresh, even if there is already a pending request. Previous requests will * not be cancelled, but their result will not affect the data/pending state - and any @@ -115,7 +115,7 @@ export interface _AsyncData { export type AsyncData = _AsyncData & Promise<_AsyncData> -// TODO: deprecate boolean option in future minor +// TODO: remove boolean option in Nuxt 4 const isDefer = (dedupe?: boolean | 'cancel' | 'defer') => dedupe === 'defer' || dedupe === false /** @@ -235,6 +235,10 @@ export function useAsyncData< options.deep = options.deep ?? asyncDataDefaults.deep options.dedupe = options.dedupe ?? 'cancel' + if (import.meta.dev && typeof options.dedupe === 'boolean') { + console.warn('[nuxt] `boolean` values are deprecated for the `dedupe` option of `useAsyncData` and will be removed in the future. Use \'cancel\' or \'defer\' instead.') + } + const hasCachedData = () => ![null, undefined].includes(options.getCachedData!(key) as any) // Create or use a shared asyncData entity