fix(editor): restore this context in EmailNode/EmailMark.create() callbacks#3062
Conversation
…onfig callbacks Add ThisType intersection to ConfigParameter type to preserve 'this' context (name, options, storage, editor, type, parent) in callbacks like renderHTML, addCommands, addAttributes. Fixes TS2353/TS2339 errors when using this.options or this.name inside config callbacks. Bump version to 0.0.0-experimental.18.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
commit: |
There was a problem hiding this comment.
cubic analysis
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Linked issue analysis
Linked issue: PRODUCT-1612: fix: EmailNode.create() type regression — this context lost in config callbacks
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Restore ThisType in EmailNode.create() config parameter so `this` has name/options/storage/editor/type/parent | Added ThisType in packages/editor/src/core/serializer/email-node.ts |
| ✅ | Restore ThisType in EmailMark.create() config parameter so `this` has name/options/storage/editor/type/parent | Added ThisType in packages/editor/src/core/serializer/email-mark.ts |
| ✅ | Keep renderToReactEmail required while making other config fields partial | ConfigParameter still uses Pick<..., 'renderToReactEmail'> |
| ✅ | Ensure callbacks (renderHTML, addCommands, addAttributes) regain typed `this` (this.name, this.options, etc.) | ThisType addition restores callback `this` context |
| ✅ | Fix implicit any on callback params (e.g. renderHTML({ node, HTMLAttributes })) by restoring typing | ConfigParameter types preserved and ThisType restored |
| ✅ | Apply same fix to EmailMark if it has the same issue | EmailMark file updated with identical ThisType fix |
| ✅ | Bump @react-email/editor version to 0.0.0-experimental.18 | package.json version updated |
| Verify EmailNode.create() and EmailMark.create() accept config callbacks with this.name and this.options without TS errors | ThisType added (likely fixes), but no typecheck run shown | |
| ❌ | Confirm typecheck passes: pnpm --filter @react-email/editor typecheck | No typecheck output or CI evidence in diffs |
| ❌ | Run lint: pnpm lint:fix | No lint changes or results shown in diffs |
Replace inferred types with explicit type annotations on all .from() extension wrappers to prevent tsdown from emitting import * for each @tiptap/extension-* package in the DTS. Replace typeof-derived StarterKitOptions with explicit type definition. Add missing export * for heading, divider, and link extensions. Export HeadingOptions, DividerOptions, and LinkOptions types.
Summary
Fixes type regression in
@react-email/editor@0.0.0-experimental.17whereEmailNode.create()andEmailMark.create()lostthiscontext in config callbacks.The
ConfigParametertype was wrapping the config inPartial<Omit<...>>, stripping theThisTypeintersection that TipTap's base implementation provides. AddedThisType<{name, options, storage, editor, type, parent}>toConfigParameterin bothemail-node.tsandemail-mark.tsto restore access tothis.name,this.options, etc. inside callbacks likerenderHTML,addCommands,addAttributes.Bumped version to
0.0.0-experimental.18.Testing steps
EmailNode.create()andEmailMark.create()accept config callbacks withthis.nameandthis.optionswithout TS errorsrenderHTML,addCommands, andaddAttributescallbacks have properthistypingpnpm --filter @react-email/editor typecheckpnpm lint:fixSummary by cubic
Restores the
thiscontext inEmailNode.create()andEmailMark.create()config callbacks in@react-email/editor, and fixes DTS import issues by using explicit types on extension wrappers. Addresses PRODUCT-1612.Bug Fixes
ThisTypetoConfigParameterfor nodes and marks to typethisinrenderHTML,addCommands, andaddAttributes, fixing TS errors withthis.name/this.options..from()extension wrappers and definedStarterKitOptionsexplicitly to preventimport *in.d.ts; exportedHeading,Divider, andLinkplus their option types.Dependencies
@react-email/editorto0.0.0-experimental.18.Written for commit 01fc68a. Summary will update on new commits.