Skip to content

test: advanced type check for ThemeName#465

Merged
Brentlok merged 2 commits intomainfrom
fix/theme-type
Mar 20, 2026
Merged

test: advanced type check for ThemeName#465
Brentlok merged 2 commits intomainfrom
fix/theme-type

Conversation

@Brentlok
Copy link
Copy Markdown
Contributor

@Brentlok Brentlok commented Mar 20, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive compile-time type-checks to validate public API typings and theme names.
  • Chores

    • Added an npm script to run the type checks.
    • Incorporated type-checking into the test pipeline so it runs as part of CI/precommit.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d0ebb0b-da22-4524-89a2-26a790a08ace

📥 Commits

Reviewing files that changed from the base of the PR and between d35761b and 3401992.

📒 Files selected for processing (1)
  • packages/uniwind/tests/type-test/theme.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/uniwind/tests/type-test/theme.ts

📝 Walkthrough

Walkthrough

Adds a compile-time type-testing suite for the UniWind package, makes the useUniwind hook's return type explicit, introduces type-test utilities and config, and wires a new test:types task into the Turbo pipeline and package scripts.

Changes

Cohort / File(s) Summary
Type Testing Utilities
packages/uniwind/tests/type-test/checks.ts
Added Equal<A, B> and Expect<T extends true> utility types for compile-time assertions.
Type Test Setup & Config
packages/uniwind/tests/type-test/setup.d.ts, packages/uniwind/tests/type-test/tsconfig.json
Module augmentation adding UniwindConfig with themes: readonly ['light','dark','premium','custom'] and a tsconfig that maps uniwind to generated declarations and enables noEmit type-only testing.
Type Verification Tests
packages/uniwind/tests/type-test/theme.ts
New type-only test file asserting ThemeName, useUniwind() theme, Uniwind API signatures, and ScopedTheme props match the expected theme union.
Hook Type Annotation
packages/uniwind/src/hooks/useUniwind.ts
Made useUniwind return type explicit: : { theme: ThemeName; hasAdaptiveThemes: boolean } and removed a redundant type assertion on the returned theme.
Build & Task Integration
packages/uniwind/package.json, turbo.json
Added test:types npm script and a test:types Turbo task (dependsOn: ["build"], cache: false); added test:types as a dependency of test and precommit.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped through types with whiskers keen,
Equal, Expect — a tidy sheen.
Compile-time checks beneath my paws,
Themes aligned with gentle laws.
Hooray for typings — snug and clean! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request: adding advanced type checking for ThemeName through new TypeScript type tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/theme-type
📝 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 disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

Copy link
Copy Markdown

@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)
packages/uniwind/tests/type-test/theme.ts (1)

1-2: Replace React.ComponentProps with explicit ComponentProps import.

Line 28 uses React.ComponentProps without an explicit import. While available through the jsx: react config, explicit imports follow TypeScript best practices and improve code clarity.

Suggested change
+import type { ComponentProps } from 'react'
 import { ScopedTheme, type ThemeName, Uniwind, useUniwind } from 'uniwind'
 import { type Equal, type Expect } from './checks'
@@
-type ScopedThemeThemeProp = React.ComponentProps<typeof ScopedTheme>['theme']
+type ScopedThemeThemeProp = ComponentProps<typeof ScopedTheme>['theme']
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/uniwind/tests/type-test/theme.ts` around lines 1 - 2, Replace uses
of React.ComponentProps with an explicit import: add an import for
ComponentProps (as a type) from 'react' and update the test to use
ComponentProps wherever React.ComponentProps is referenced (e.g. in the type
assertions around ScopedTheme, ThemeName, Uniwind, useUniwind). Ensure the
import is a type import (import type { ComponentProps } from 'react') and remove
the React. prefix from the existing type usages.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/uniwind/tests/type-test/theme.ts`:
- Around line 1-2: Replace uses of React.ComponentProps with an explicit import:
add an import for ComponentProps (as a type) from 'react' and update the test to
use ComponentProps wherever React.ComponentProps is referenced (e.g. in the type
assertions around ScopedTheme, ThemeName, Uniwind, useUniwind). Ensure the
import is a type import (import type { ComponentProps } from 'react') and remove
the React. prefix from the existing type usages.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b8c79ac6-0bd6-4280-93fa-f63701e920ea

📥 Commits

Reviewing files that changed from the base of the PR and between c06b616 and d35761b.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • packages/uniwind/package.json
  • packages/uniwind/src/hooks/useUniwind.ts
  • packages/uniwind/tests/type-test/checks.ts
  • packages/uniwind/tests/type-test/setup.d.ts
  • packages/uniwind/tests/type-test/theme.ts
  • packages/uniwind/tests/type-test/tsconfig.json
  • turbo.json

@Brentlok Brentlok merged commit 9fca689 into main Mar 20, 2026
2 checks passed
@Brentlok Brentlok deleted the fix/theme-type branch March 20, 2026 14:14
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This pull request is included in v1.6.1. See Release v1.6.1 for release notes.

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