Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/types/cookies.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expectError, expectType } from 'tsd'
import { Headers, deleteCookie } from '../..'

const headers = new Headers()

// `path` and `domain` should be accepted as deleteCookie attributes.
expectType<void>(deleteCookie(headers, 'session', {
domain: 'example.com',
path: '/'
}))

expectType<void>(deleteCookie(headers, 'session', { path: '/' }))
expectType<void>(deleteCookie(headers, 'session', { domain: 'example.com' }))

// `name` should not be accepted because the cookie name is the second positional argument.
expectError(deleteCookie(headers, 'session', {
domain: 'example.com',
name: 'session'
}))
2 changes: 1 addition & 1 deletion types/cookies.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Cookie {
export function deleteCookie (
headers: Headers,
name: string,
attributes?: { name?: string, domain?: string }
attributes?: { path?: string, domain?: string }
): void

export function getCookies (headers: Headers): Record<string, string>
Expand Down
Loading