Skip to content

Add canBeForwarded to ForwardableEmailMessage types - #8371

Merged
cjol merged 1 commit into
mainfrom
cjol/email-can-be-forwarded-type
Nov 12, 2026
Merged

cjol merged 1 commit into
mainfrom
cjol/email-can-be-forwarded-type

Conversation

@cjol

@cjol cjol commented Nov 11, 2026

Copy link
Copy Markdown
Member

Production exposes canBeForwarded as a read-only boolean on the ForwardableEmailMessage passed to a Worker's email() handler, and the Email Service docs list it, but types/defines/email.d.ts omits it. As a result, message.canBeForwarded is a type error in user code.

This adds readonly canBeForwarded: boolean to 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 use satisfies 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 the defines/ change, because defines are copied into the output verbatim. The snapshot CI check should confirm they match just generate-types. I type-checked types/test/types/email.ts against the updated experimental snapshot locally with tsc 5.9.

🤖 Generated with Claude Code

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>
@cjol
cjol requested review from a team as code owners November 11, 2026 17:55
@cjol
cjol requested a review from jamesopstad November 11, 2026 17:55

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 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:44 adds readonly canBeForwarded: boolean with a doc comment. It is placed alongside the other read-only message properties.
  • types/test/types/email.ts:53-56 checks that the property is boolean. It also uses @ts-expect-error to 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 run just generate-types instead. The added lines match the defines/ 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

Comment thread types/generated-snapshot/index.ts Resolved
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.48%. Comparing base (16784a2) to head (644dd2a).
⚠️ Report is 8 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cjol
cjol merged commit 22a428d into main Nov 12, 2026
23 checks passed
@cjol
cjol deleted the cjol/email-can-be-forwarded-type branch November 12, 2026 09:51
edmundhung added a commit to cloudflare/workers-sdk that referenced this pull request Nov 13, 2026
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.
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.

4 participants