Fix TS2769 build error in node renderer onFile callback#2469
Fix TS2769 build error in node renderer onFile callback#2469AbanoubGhadban merged 1 commit intomasterfrom
Conversation
The `onFile` callback in worker.ts annotated `this` with the local Http2Server-typed `FastifyRequest`, but @fastify/multipart types expect the default (RawServerDefault) `FastifyRequest`. This caused a type mismatch (`IncomingMessage` missing `authority`, `scheme`, `stream` from `Http2ServerRequest`) that broke `pnpm build` and `pnpm install`. Remove the explicit `this: FastifyRequest` annotation so TypeScript contextually infers the correct type from the plugin's definition. Fixes #2467 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 WalkthroughThe pull request fixes a TypeScript type annotation incompatibility in the multipart file handler. The explicit Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
ReviewOverall: Correct fix, approve with one note The root cause is clear: the local Removing the annotation lets TypeScript infer What holds the fix together:
Minor note worth tracking: The explanatory comment added alongside the change is helpful for future maintainers. |
| async onFile(this: FastifyRequest, part) { | ||
| // Note: do NOT annotate `this` with the local Http2Server-typed FastifyRequest; | ||
| // the plugin types expect the default (RawServerDefault) FastifyRequest. | ||
| async onFile(part) { |
There was a problem hiding this comment.
The fix is correct. One thing worth noting for future maintainers: this here is now typed by @fastify/multipart's overload rather than the local Http2Server-parameterized alias. That's safe today because the global module augmentation (declare module 'fastify' { interface FastifyRequest { uploadDir: string } }, lines 51–56) patches whichever concrete FastifyRequest the plugin resolves to.
If a future @fastify/multipart upgrade ever changes its onFile overload to type this as unknown or any, the this.uploadDir accesses below would silently lose type coverage. The runtime guard on line 182 mitigates that, but a quick tsc check after any multipart version bump is worthwhile.
Greptile SummaryFixes TypeScript build error ( The issue occurred because the local Solution: Removed the explicit Key changes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: ee46f99 |
## Summary - Removes the explicit `this: FastifyRequest` (Http2Server-typed) annotation from the `onFile` callback in `worker.ts`, which was incompatible with `@fastify/multipart`'s type definitions that expect the default `RawServerDefault` `FastifyRequest` - This fixes the `TS2769: No overload matches this call` error that broke `pnpm build` and `pnpm install` on fresh runners (where the `prepare` script runs `tsc`) Fixes #2467 ## Test plan - [x] `pnpm install` succeeds (triggers `prepare` → `tsc`) - [x] `pnpm build` succeeds in `packages/react-on-rails-pro-node-renderer` - [x] `pnpm type-check` succeeds in `packages/react-on-rails-pro-node-renderer` - [ ] CI `check-bundle-size` job passes on a fresh runner (no cached `lib/`) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved internal type annotations for file handling functionality. No user-facing changes or functionality modifications. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.6 <[email protected]>
## Summary - Removes the explicit `this: FastifyRequest` (Http2Server-typed) annotation from the `onFile` callback in `worker.ts`, which was incompatible with `@fastify/multipart`'s type definitions that expect the default `RawServerDefault` `FastifyRequest` - This fixes the `TS2769: No overload matches this call` error that broke `pnpm build` and `pnpm install` on fresh runners (where the `prepare` script runs `tsc`) Fixes #2467 ## Test plan - [x] `pnpm install` succeeds (triggers `prepare` → `tsc`) - [x] `pnpm build` succeeds in `packages/react-on-rails-pro-node-renderer` - [x] `pnpm type-check` succeeds in `packages/react-on-rails-pro-node-renderer` - [ ] CI `check-bundle-size` job passes on a fresh runner (no cached `lib/`) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved internal type annotations for file handling functionality. No user-facing changes or functionality modifications. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
this: FastifyRequest(Http2Server-typed) annotation from theonFilecallback inworker.ts, which was incompatible with@fastify/multipart's type definitions that expect the defaultRawServerDefaultFastifyRequestTS2769: No overload matches this callerror that brokepnpm buildandpnpm installon fresh runners (where thepreparescript runstsc)Fixes #2467
Test plan
pnpm installsucceeds (triggersprepare→tsc)pnpm buildsucceeds inpackages/react-on-rails-pro-node-rendererpnpm type-checksucceeds inpackages/react-on-rails-pro-node-renderercheck-bundle-sizejob passes on a fresh runner (no cachedlib/)🤖 Generated with Claude Code
Summary by CodeRabbit