Skip to content

chore: add native TypeScript type definitions for v3#77

Merged
nfriedly merged 2 commits intonfriedly:masterfrom
jlowcs:add-typescript-types
Mar 20, 2026
Merged

chore: add native TypeScript type definitions for v3#77
nfriedly merged 2 commits intonfriedly:masterfrom
jlowcs:add-typescript-types

Conversation

@jlowcs
Copy link
Contributor

@jlowcs jlowcs commented Mar 17, 2026

Closes #75. Bundles type definitions directly in the package so consumers no longer need @types/set-cookie-parser.

Key changes vs the v2 DefinitelyTyped types:

  • Primary export is parseSetCookie; parse, parseString, and splitCookiesString are marked @deprecated
  • New split option (boolean | "auto")
  • New partitioned cookie attribute
  • Broader input type accepting fetch Response objects

To be transparent, this was mostly generated with Claude Code based on the source code and the v2 @types types. I've reviewed it but I haven't tested it extensively.

Closes nfriedly#75. Bundles type definitions directly in the package so
consumers no longer need @types/set-cookie-parser.

Key changes vs the v2 DefinitelyTyped types:
- Primary export is parseSetCookie; parse, parseString, and
  splitCookiesString are marked @deprecated
- New split option (boolean | "auto")
- New partitioned cookie attribute
- Broader input type accepting fetch Response objects

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jlowcs jlowcs changed the title Add native TypeScript type definitions for v3 chore: add native TypeScript type definitions for v3 Mar 17, 2026
@jlowcs jlowcs mentioned this pull request Mar 17, 2026
@nfriedly
Copy link
Owner

Hey, thanks for this. I don't imagine many significant changes going forward, but is there a good way to automatically validate that the types match the library?

@nfriedly
Copy link
Owner

Oh, I just saw your other comment at #75 (comment) - yes, I would appreciate the tsd tests. And maybe a unit test that's written in typescript and uses the types to do a couple of basic operations with the library?

Adds lib/set-cookie.test-d.ts exercising all type definitions and
a "typecheck" npm script that runs as part of "npm test".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jlowcs
Copy link
Contributor Author

jlowcs commented Mar 17, 2026

I've added tsd, but I don't think the unit test is worth adding, as you would have to add transpiling dependencies (like typescript or swc). tsd should be enough imho.

@nfriedly
Copy link
Owner

Awesome, thank you! (And sorry for the delay - part of my roof got blown off in a windstorm the other day, so it's been a busy week!)

I think you're right that this is a sufficient level of testing. I may add some more eventually, but this is good enough for now.

Thanks again!

@nfriedly nfriedly merged commit bfaf020 into nfriedly:master Mar 20, 2026
3 checks passed
@nfriedly
Copy link
Owner

It's now live in v3.1.0 - https://www.npmjs.com/package/set-cookie-parser

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.

Provide TypeScript types

2 participants