fix: type rawBody as optional since it can be undefined - #176
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Koa 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis pull request updates the TypeScript declaration of the File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Closes #174
The module augments
koa.Requestandhttp.IncomingMessagewithrawBody: string, but at runtime the property is only assigned when a body is actually parsed — it remainsundefinedfor unsupported content types, disabled parsers, closed requests, or when the request is skipped. WithskipLibCheck: false(or in strict consumer projects) TypeScript reportsrawBodyas always a string, which is misleading and can hide runtime bugs.Change
koa.Request.rawBody→string | undefined(optional)http.IncomingMessage.rawBody→string | undefined(optional)The existing test suite already asserts the
undefinedbehavior (e.g.expect(ctx.request.rawBody).toEqual(undefined)intest/middleware.test.ts), so this only aligns the declared types with the implemented behavior.Verification
npm test: 34 passednpm run build(tsup + dts): successSummary by Sourcery
Align type declarations of rawBody with its runtime behavior by making it optional on Koa and Node request objects.
Bug Fixes:
Summary by CodeRabbit