Skip to content

types: fix deleteCookie attributes#5460

Open
mayur-shenoy wants to merge 1 commit into
nodejs:mainfrom
mayur-shenoy:fix-delete-cookie-types
Open

types: fix deleteCookie attributes#5460
mayur-shenoy wants to merge 1 commit into
nodejs:mainfrom
mayur-shenoy:fix-delete-cookie-types

Conversation

@mayur-shenoy

Copy link
Copy Markdown

This relates to...

Fixes #5458

Rationale

deleteCookie(headers, name, attributes) accepts path and domain at runtime, but the TypeScript declaration exposed name and domain.

The cookie name is already provided as the second argument, so name should not be accepted inside the attributes object. This updates the declaration to match the runtime behavior and existing cookie usage.

Changes

Updates the deleteCookie TypeScript declaration and adds tsd coverage for the accepted/rejected attributes.

Features

N/A

Bug Fixes

  • Allows deleteCookie(headers, name, { path: '/' }) in TypeScript
  • Rejects deleteCookie(headers, name, { name: '...' }) in TypeScript
  • Keeps domain supported as before

Breaking Changes and Deprecations

N/A

Status

Signed-off-by: mayur-shenoy <mayurshenoy2005@gmail.com>
Copilot AI review requested due to automatic review settings June 29, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns Undici’s TypeScript declarations for deleteCookie() with its documented/runtime behavior, fixing a type drift that prevented valid { path } usage while incorrectly allowing { name } inside the attributes object.

Changes:

  • Update deleteCookie(headers, name, attributes) typing to accept { path?: string, domain?: string } instead of { name?: string, domain?: string }.
  • Add tsd coverage to ensure { path } is accepted and { name } is rejected in TypeScript.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
types/cookies.d.ts Fixes the deleteCookie attributes type to allow path and disallow redundant name, matching runtime/docs.
test/types/cookies.test-d.ts Adds tsd assertions for accepted/rejected deleteCookie attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deleteCookie TypeScript attributes expose name instead of path

2 participants