From 3768aeaf32b72ba2d29ca4055c35340c036fa2c9 Mon Sep 17 00:00:00 2001 From: Wisnu Wicaksono <63142229+wiscaksono@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:05:40 +0700 Subject: [PATCH] Documentation Fix: Correct `cacheTag` Function Usage (#71912) ## What? ### Documentation Fix: Correct `cacheTag` Function Usage **Issue**: The [current documentation](https://nextjs.org/docs/canary/app/api-reference/functions/cacheTag#notes) incorrectly states that `cacheTag` accepts an array of tags. However, the [source code](https://github.com/vercel/next.js/blob/ca5f29d81b011c3a01e2372118b29836f1df0fa7/packages/next/src/server/use-cache/cache-tag.ts#L4C1-L4C52) implementation uses rest parameters (`...tags: string[]`), expecting individual string arguments rather than an array. **Changes**: Updated the "Notes" section to reflect the function's correct usage: ## Why? This change: 1. Aligns with the actual implementation in the source code 2. Prevents TypeScript errors when users follow the documentation 3. Provides clearer guidance on using the function with both direct arguments and arrays (using the spread operator) The current documentation might lead developers to encounter the TypeScript error: > "Argument of type 'string[]' is not assignable to parameter of type 'string'" ## Related Fixes #71901 Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com> --- docs/02-app/02-api-reference/04-functions/cacheTag.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/02-app/02-api-reference/04-functions/cacheTag.mdx b/docs/02-app/02-api-reference/04-functions/cacheTag.mdx index 46ceaf62b88a7..b86287064e860 100644 --- a/docs/02-app/02-api-reference/04-functions/cacheTag.mdx +++ b/docs/02-app/02-api-reference/04-functions/cacheTag.mdx @@ -132,5 +132,5 @@ export async function updateBookings() { - **Multiple Tags**: You can assign multiple tags to a single cache entry by passing an array to `cacheTag`. ```tsx -cacheTag(['tag-one', 'tag-two']) +cacheTag('tag-one', 'tag-two') ```