Skip to content

refactor: improve AccentColorId type constraints#1972

Merged
serhalp merged 3 commits intonpmx-dev:mainfrom
mcontrib:refactor/improve-accent-color-id-typing
Mar 15, 2026
Merged

refactor: improve AccentColorId type constraints#1972
serhalp merged 3 commits intonpmx-dev:mainfrom
mcontrib:refactor/improve-accent-color-id-typing

Conversation

@maxchang3
Copy link
Contributor

@maxchang3 maxchang3 commented Mar 7, 2026

🔗 Linked issue

/

🧭 Context

Currently, there are two typing issues regarding ACCENT_COLORS within the project:

  1. onPrehydrate requires runtime-hardcoded values, which made local accentColorIds in prehydrate.ts easy to drift from the shared accent color constant (See fix: add neutral to accentColorIds in prehydration #1797).

  2. ACCENT_COLORS was previously defined as a plain const, which did not enforce complete key alignment between light and dark.

📚 Description

This PR only improves type safety and consistency without affecting runtime behavior:

  • Add shared ACCENT_COLOR_IDS const and export the inferred union type AccentColorId.
  • Add type constraints to enforce strict alignment of light/dark keys in ACCENT_COLORS.
  • Add type constraints to accentColorIds in prehydrate.ts to ensure it remains in sync with ACCENT_COLOR_IDS.

@vercel
Copy link

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Mar 12, 2026 6:32pm
npmx.dev Ready Ready Preview, Comment Mar 12, 2026 6:32pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Mar 12, 2026 6:32pm

Request Review

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a7702f7-d881-4244-816e-1114cfc23493

📥 Commits

Reviewing files that changed from the base of the PR and between d323973 and 1f474dc.

📒 Files selected for processing (1)
  • app/composables/useSettings.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/composables/useSettings.ts

📝 Walkthrough

Walkthrough

The PR centralises accent-colour definitions and tightens typing: it adds ACCENT_COLOR_IDS and an exported AccentColorId type in shared/utils/constants.ts, narrows ACCENT_COLORS with a satisfies Record type, replaces a local AccentColorId alias in app/composables/useSettings.ts with the imported type, and updates app/utils/prehydrate.ts to validate its accent ID array with a satisfies check. Changes are type-level only; runtime logic is unchanged.

Possibly related PRs

Suggested labels

front

Suggested reviewers

  • serhalp
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly outlines the typing issues being addressed and explains the changes made to improve type safety without affecting runtime behaviour.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

Copy link
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/utils/prehydrate.ts (1)

13-21: ⚠️ Potential issue | 🔴 Critical

Add import for ACCENT_COLOR_IDS or use a module type query to avoid build-time type error.

ACCENT_COLOR_IDS is not declared or imported in this file, and the Nuxt auto-import configuration does not extend to #shared/utils/constants. Using satisfies typeof ACCENT_COLOR_IDS will cause a TypeScript build failure. Either add an explicit import statement or use a module type query to keep the type check self-contained within the function.

Suggested change
-    ] satisfies typeof ACCENT_COLOR_IDS)
+    ] satisfies typeof import('#shared/utils/constants').ACCENT_COLOR_IDS)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72907f03-528e-485a-bc58-660e6c50e9f3

📥 Commits

Reviewing files that changed from the base of the PR and between 0d952fa and d323973.

📒 Files selected for processing (3)
  • app/composables/useSettings.ts
  • app/utils/prehydrate.ts
  • shared/utils/constants.ts

@maxchang3
Copy link
Contributor Author

maxchang3 commented Mar 10, 2026

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)

app/utils/prehydrate.ts (1)> 13-21: ⚠️ Potential issue | 🔴 Critical

Add import for ACCENT_COLOR_IDS or use a module type query to avoid build-time type error.
ACCENT_COLOR_IDS is not declared or imported in this file, and the Nuxt auto-import configuration does not extend to #shared/utils/constants. Using satisfies typeof ACCENT_COLOR_IDS will cause a TypeScript build failure. Either add an explicit import statement or use a module type query to keep the type check self-contained within the function.

Suggested change

-    ] satisfies typeof ACCENT_COLOR_IDS)
+    ] satisfies typeof import('#shared/utils/constants').ACCENT_COLOR_IDS)

ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72907f03-528e-485a-bc58-660e6c50e9f3

📥 Commits
Reviewing files that changed from the base of the PR and between 0d952fa and d323973.

📒 Files selected for processing (3)

This is only used for typing. So it won’t introduce a runtime import and will be erased during compilation.

Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

nice!

@serhalp serhalp added this pull request to the merge queue Mar 15, 2026
Merged via the queue into npmx-dev:main with commit 4422cba Mar 15, 2026
20 checks passed
@github-actions github-actions bot mentioned this pull request Mar 15, 2026
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