Repository navigation
Add canBeForwarded to ForwardableEmailMessage types - #8371
Conversation
Production exposes `canBeForwarded` as a read-only boolean on the message passed to a Worker's `email()` handler, and the Email Service docs list it, but the type definition omitted it. Reading `message.canBeForwarded` was therefore a type error in user code. The generated snapshots were updated by hand, mirroring the defines change verbatim; the snapshot CI check verifies them against `just generate-types`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💬 Approved with comments — A small, correct type addition with a matching type test. The only note is an INFO that the generated snapshots were edited by hand instead of regenerated.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 info
The type and test are correct. The generated snapshots were edited by hand.
Recommendation: 💬 Optional Nits
- [INFO] Generated snapshot files were edited by hand instead of being regenerated with
just generate-types. (types/generated-snapshot/index.ts:15157)
View full review
types/defines/email.d.ts:44addsreadonly canBeForwarded: booleanwith a doc comment. It is placed alongside the other read-only message properties.types/test/types/email.ts:53-56checks that the property isboolean. It also uses@ts-expect-errorto check that assigning to it is rejected.- The four
types/generated-snapshot/files were edited by hand. The repository's instructions say never to edit them directly and to runjust generate-typesinstead. The added lines match thedefines/change exactly, so this is likely fine, but the snapshot CI check or a regeneration should confirm it.
✅ All other checks passed
📝 Documentation: ✅ LGTM
The new canBeForwarded doc comment ("Whether this email message can be forwarded with forward().") is clear and matches the style of the surrounding comments. The note about the hand-edited snapshots is in the code quality section.
Reviewed commit: 644dd2aa
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8371 +/- ##
==========================================
- Coverage 65.67% 65.48% -0.19%
==========================================
Files 764 767 +3
Lines 194512 195260 +748
Branches 30695 30728 +33
==========================================
+ Hits 127739 127863 +124
- Misses 48965 49582 +617
- Partials 17808 17815 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
workers-types 5.20261113.1 adds a required `canBeForwarded` to `ForwardableEmailMessage` (cloudflare/workerd#8371). Miniflare's local email message doesn't set it yet, so `satisfies ForwardableEmailMessage` fails the build. Leave the property out of the check until #16811 adds it.
Production exposes
canBeForwardedas a read-only boolean on theForwardableEmailMessagepassed to a Worker'semail()handler, and the Email Service docs list it, buttypes/defines/email.d.tsomits it. As a result,message.canBeForwardedis a type error in user code.This adds
readonly canBeForwarded: booleanto the interface, along with a type test that checks both its type and that it's read-only.Context: cloudflare/workers-sdk#16811 adds the property to Miniflare's local
email()implementation. Until this lands, it has to usesatisfies ForwardableEmailMessage & { canBeForwarded: boolean }.Note on snapshots: I didn't have a Bazel toolchain available, so I edited the four
generated-snapshot/files by hand. Each gets the same lines as thedefines/change, because defines are copied into the output verbatim. The snapshot CI check should confirm they matchjust generate-types. I type-checkedtypes/test/types/email.tsagainst the updated experimental snapshot locally with tsc 5.9.🤖 Generated with Claude Code