Skip to content

Runtime and TS types of getCookies are wrong (still) #7053

@Ionaru

Description

@Ionaru

Describe the bug

The getCookies function returns the type Record<string, string>, telling Typescript that any value within the result is a string.

Related: #6852

Steps to Reproduce

const cookieValue = getCookies(new Headers([['cookie', 'key=val']])).someOtherCookie
// cookieValue is undefined here, but Typescript thinks it's a string.

Expected behavior

const cookieValue = getCookies(new Headers([['cookie', 'key=val']])).someOtherCookie
// Typescript correctly knows that cookieValue can be undefined. (string | undefined)

Environment

  • OS: Windows 11
  • deno version: 2.7.5
  • std version: @std/http 1.0.25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghttp

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions