Skip to content

refactor: improve AccentColorId type constraints#1972

Open
maxchang3 wants to merge 1 commit intonpmx-dev:mainfrom
mcontrib:refactor/improve-accent-color-id-typing
Open

refactor: improve AccentColorId type constraints#1972
maxchang3 wants to merge 1 commit 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)
npmx.dev Error Error Mar 7, 2026 9:24am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 7, 2026 9:24am
npmx-lunaria Ignored Ignored Mar 7, 2026 9:24am

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

📝 Walkthrough

Walkthrough

The pull request centralises accent colour type definitions and improves type safety across the codebase. A new ACCENT_COLOR_IDS constant array is introduced in shared utilities, along with an exported AccentColorId type derived from it. The ACCENT_COLORS constant receives stricter typing via a satisfies constraint. The local type alias in useSettings.ts is removed and replaced with the imported AccentColorId type. The prehydrate.ts file is updated to validate its accent colour array against the centralised constant using a satisfies check.

Possibly related PRs

Suggested reviewers

  • danielroe
  • serhalp
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description accurately explains the typing improvements, references the specific issue (#1797), and details the changes made across three files.

✏️ 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

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
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

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