Skip to content

fix(types): tighten parseCookie return type#287

Open
Hashim1999164 wants to merge 1 commit into
jshttp:masterfrom
Hashim1999164:fix/parse-cookie-types
Open

fix(types): tighten parseCookie return type#287
Hashim1999164 wants to merge 1 commit into
jshttp:masterfrom
Hashim1999164:fix/parse-cookie-types

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

  • Make parseCookie generic over the decode option so the return type mirrors the decoder.
  • Default parse result is now Record<string, string> instead of Record<string, string | undefined>.
  • Custom decoders that return undefined (or other types) keep accurate typing via generics.
  • stringifyCookie still accepts undefined values so existing skip behavior is unchanged.

Fixes #252

Test plan

  • npm test (tsc, prettier, vitest, size-limit)
  • Added expectTypeOf checks for default and custom decode return types

@Hashim1999164
Hashim1999164 force-pushed the fix/parse-cookie-types branch from 70ecc88 to c7fda13 Compare July 26, 2026 19:36
@Hashim1999164
Hashim1999164 force-pushed the fix/parse-cookie-types branch 2 times, most recently from 362910c to 6dbfabb Compare July 26, 2026 19:37
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.

Typing on parse; parse returns Record<string, string | undefined>

1 participant