Skip to content

mail-react: Enable TypeScript strict mode - #6259

Draft
VPS-thodax wants to merge 8 commits into
mainfrom
claude/com-1079-strict-mail-react
Draft

mail-react: Enable TypeScript strict mode#6259
VPS-thodax wants to merge 8 commits into
mainfrom
claude/com-1079-strict-mail-react

Conversation

@VPS-thodax

@VPS-thodax VPS-thodax commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Status quo

Strict mode is not enabled everywhere in this repo. @dextinity/mail-react extends tsconfig.core.json directly, which sets neither strictNullChecks nor noImplicitAny, so neither applied to this package so far.

Change

Enable strict for the package and fix the two resulting errors.

strictNullChecks also makes the return type of OneOfBlock and OptionalBlock nullable. Both already returned null in some branches, so this only corrects the emitted types — see the changeset.

Verification

Compared the emitted .d.ts files against main: those two return types are the only difference, so the changeset covers the full public type change. HtmlText.d.ts is byte-identical despite the removed index signature — it only ever served the implementation signature, which TypeScript does not emit.

Further information

Note

Enable TypeScript strict mode in mail-react

  • Adds "strict": true to tsconfig.json for @dextinity/mail-react
  • Removes the string index signature from HtmlTextImplementationProps in HtmlText.tsx, narrowing props to declared fields only
  • Makes OneOfBlock and OptionalBlock return types nullable to match existing runtime behavior, per the changeset
  • Wraps a conditional render in a React.Fragment in MjmlWarningsPanel.tsx
  • Risk: removing the [key: string]: unknown index signature on HtmlTextImplementationProps will cause type errors for any callers passing undeclared props

Macroscope summarized 45e1ba9. (Automatic summaries will resume when PR exits draft mode or review begins).

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/mail-react/src/storybook/MjmlWarningsPanel.tsx Outdated
Comment thread packages/mail-react/src/components/text/HtmlText.tsx
Strict mode is enabled in the starter, so the packages should follow.

The package extended tsconfig.core.json directly, which sets neither
strictNullChecks nor noImplicitAny, so this is the first time either
applies here. It makes the nullable return values of OneOfBlock and
OptionalBlock visible in the emitted types.

Drop the index signature from HtmlTextImplementationProps: with
strictFunctionTypes, an "unknown"-valued index signature makes the
implementation signature incompatible with the element-specific
overloads. The index signature only served the internal implementation
signature, so removing it neither changes the public overloads nor how
the remaining props are forwarded.
@VPS-thodax
VPS-thodax force-pushed the claude/com-1079-strict-mail-react branch from 779938a to 10d1f6c Compare August 31, 2026 12:29
claude added 3 commits August 31, 2026 13:28
Review asked why removing it is safe. Record it where the next reader
looks: the implementation signature is never emitted, so callers only
ever see the overloads.
The reasoning behind the removed index signature belongs in the review
conversation, not in the code.

Copy link
Copy Markdown
Contributor Author

Why dropping the index signature from HtmlTextImplementationProps is safe

HtmlTextImplementationProps types the implementation signature of HtmlText. TypeScript emits only the overload signatures of an overloaded function, never the implementation — so this type never reaches consumers. It is also not exported.

Checked rather than assumed:

  • Built the package from main and from this branch and compared the emitted declarations. HtmlText.d.ts is byte-identical, and the type does not appear in it at all.
  • Compiled a probe in the demo API against both builds: element="a" href, colSpan, element="div", plus an unknown attribute. Identical results in both, including that the unknown attribute is rejected either way — the overloads decide which props are accepted, the index signature never did.

Inside the implementation the remaining props are still spread onto the element exactly as before; only their static types are lost, and only within that function body.

The reason the index signature had to go: with strictFunctionTypes, an unknown-valued index signature makes the implementation signature incompatible with the element-specific overloads (TS2394). Dropping it was the smallest fix — the alternative was widening it to any plus an eslint-disable for no-explicit-any.


Generated by Claude Code

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.

2 participants