On-demand Rendering Adapters @ Cookies examples are not working - Correct implementation provided #8612
Labels
help - confirm behaviour
Walk through the example/issue and confirm this is a general behaviour, or a correct update to make.
improve documentation
Enhance existing documentation (e.g. add an example, improve description)
📚 Subject area/topic
On-demand Rendering Adapters @ Cookies
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/server-side-rendering/#cookies
https://docs.astro.build/en/reference/api-reference/#set
📋 Description of content that is out-of-date or incorrect
Given example does not work anymore and is likely due to being outdated, because the
Astro.cookies.set("counter",counter)
accepts typeskey: string, value: string | Record<string, any>, options?: AstroCookieSetOptions
instead of(key: string, value: string | number | boolean | object, options?: CookieSetOptions) => void
. Example works only fornpm run dev
, but fails withnpm run build
with TypeScript error 2345.Also to note, there's also TypeScript error 2532, as the
cookie
value inconst cookie = Astro.cookies.get("counter")
might be undefined and fixed with!.
parameter like soconst cookie = Astro.cookies!.get("counter")
.Broken example:
Working basic example using Record type, compiles without error nor warnings.
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response
The text was updated successfully, but these errors were encountered: