chore: add native TypeScript type definitions for v3#77
chore: add native TypeScript type definitions for v3#77nfriedly merged 2 commits intonfriedly:masterfrom
Conversation
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>
|
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? |
|
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>
|
I've added |
|
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! |
|
It's now live in v3.1.0 - https://www.npmjs.com/package/set-cookie-parser |
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:
To be transparent, this was mostly generated with Claude Code based on the source code and the v2
@typestypes. I've reviewed it but I haven't tested it extensively.