Skip to content

Moved member welcome email constants file to TypeScript#27685

Merged
troyciesco merged 1 commit intomainfrom
welcome-email-constants-ts
May 5, 2026
Merged

Moved member welcome email constants file to TypeScript#27685
troyciesco merged 1 commit intomainfrom
welcome-email-constants-ts

Conversation

@troyciesco
Copy link
Copy Markdown
Contributor

@troyciesco troyciesco commented May 5, 2026

no ref

  • no user impact
  • moves the member welcome email constants file to TypeScript and improves the types a bit

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Walkthrough

This change enhances TypeScript type definitions in the member welcome emails constants module. The MEMBER_WELCOME_EMAIL_SLUGS and MEMBER_WELCOME_EMAIL_ELIGIBLE_STATUSES objects are now declared with as const assertions to preserve their literal types. Additionally, the memberWelcomeEmailInactive message definition is updated to include an explicit memberStatus: string parameter type annotation in its arrow function. The module's exported constants and overall structure remain unchanged, with only internal typing improvements applied.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: moving the member welcome email constants file to TypeScript.
Description check ✅ Passed The description is related to the changeset, mentioning the move to TypeScript and type improvements that align with the actual changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch welcome-email-constants-ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ghost/core/core/server/services/member-welcome-emails/constants.ts (1)

23-24: ⚡ Quick win

Narrow memberStatus to a derived union instead of string.

The parameter currently accepts any string, but runtime analysis shows memberStatus is always one of the keys from MEMBER_WELCOME_EMAIL_SLUGS ('free' or 'paid'). Deriving the type from this constant ensures compile-time safety and prevents invalid values from being passed.

Proposed change
+type MemberWelcomeEmailStatus = keyof typeof MEMBER_WELCOME_EMAIL_SLUGS;
+
 const MESSAGES = {
@@
-    memberWelcomeEmailInactive: (memberStatus: string) => `Member welcome email for "${memberStatus}" members is inactive`
+    memberWelcomeEmailInactive: (memberStatus: MemberWelcomeEmailStatus) => `Member welcome email for "${memberStatus}" members is inactive`
 } as const;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ghost/core/core/server/services/member-welcome-emails/constants.ts` around
lines 23 - 24, The memberWelcomeEmailInactive function currently types
memberStatus as string; narrow it to the actual keys of
MEMBER_WELCOME_EMAIL_SLUGS by changing the parameter to a derived union (e.g.
use keyof typeof MEMBER_WELCOME_EMAIL_SLUGS or define a MemberStatus = keyof
typeof MEMBER_WELCOME_EMAIL_SLUGS type) so
memberWelcomeEmailInactive(memberStatus: MemberStatus) => ... uses the
constrained union instead of string; update any related exported
types/signatures in constants.ts to use that derived type.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ghost/core/core/server/services/member-welcome-emails/constants.ts`:
- Around line 23-24: The memberWelcomeEmailInactive function currently types
memberStatus as string; narrow it to the actual keys of
MEMBER_WELCOME_EMAIL_SLUGS by changing the parameter to a derived union (e.g.
use keyof typeof MEMBER_WELCOME_EMAIL_SLUGS or define a MemberStatus = keyof
typeof MEMBER_WELCOME_EMAIL_SLUGS type) so
memberWelcomeEmailInactive(memberStatus: MemberStatus) => ... uses the
constrained union instead of string; update any related exported
types/signatures in constants.ts to use that derived type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c82bd1d2-5fd2-4c75-bdc5-6bba6d44c924

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddd8db and 3d859e8.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/member-welcome-emails/constants.ts

@troyciesco troyciesco merged commit d713982 into main May 5, 2026
44 checks passed
@troyciesco troyciesco deleted the welcome-email-constants-ts branch May 5, 2026 20:51
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.

1 participant