Skip to content

Forced cookie path change breaks re-use of CookieSerializeOptions #11799

@hmnd

Description

@hmnd

Describe the bug

The event.cookies.[get/set/delete] options type is no longer compatible with the CookieSerializeOptions type from cookie, with no alternative type provided by @sveltejs/kit.

Reproduction

const cookieOptions: CookieSerializeOptions = { path: base || '/', secure: true };
event.cookies.delete('session_id', cookieOptions);
event.cookies.delete('access_token', cookieOptions);
event.cookies.delete('refresh_token', cookieOptions);

results in this error:

Argument of type 'CookieSerializeOptions' is not assignable to parameter of type 'CookieSerializeOptions & { path: string; }'.
  Type 'CookieSerializeOptions' is not assignable to type '{ path: string; }'.
    Types of property 'path' are incompatible.
      Type 'string | undefined' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.

Logs

No response

System Info

System:
    OS: Linux 6.6 Manjaro Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 8.15 GB / 15.54 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.asdf/installs/nodejs/20.10.0/bin/node
    npm: 10.2.3 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.14.0 - ~/.local/share/pnpm/pnpm
  Browsers:
    Brave Browser: 121.1.62.153
    Chromium: 120.0.6099.129

Severity

annoyance

Additional Information

Change happened in Ideally, SvelteKit should export its own CookieSerializeOptions, to make such reuse of options more ergonomic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions