mail-react: Enable TypeScript strict mode - #6259
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
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.
779938a to
10d1f6c
Compare
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.
Why dropping the index signature from
|
Status quo
Strict mode is not enabled everywhere in this repo.
@dextinity/mail-reactextendstsconfig.core.jsondirectly, which sets neitherstrictNullChecksnornoImplicitAny, so neither applied to this package so far.Change
Enable
strictfor the package and fix the two resulting errors.strictNullChecksalso makes the return type ofOneOfBlockandOptionalBlocknullable. Both already returnednullin some branches, so this only corrects the emitted types — see the changeset.Verification
Compared the emitted
.d.tsfiles againstmain: those two return types are the only difference, so the changeset covers the full public type change.HtmlText.d.tsis 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"strict": trueto tsconfig.json for@dextinity/mail-reactHtmlTextImplementationPropsin HtmlText.tsx, narrowing props to declared fields onlyOneOfBlockandOptionalBlockreturn types nullable to match existing runtime behavior, per the changesetReact.Fragmentin MjmlWarningsPanel.tsx[key: string]: unknownindex signature onHtmlTextImplementationPropswill cause type errors for any callers passing undeclared propsMacroscope summarized 45e1ba9. (Automatic summaries will resume when PR exits draft mode or review begins).