Skip to content

Fix: CSS - More strict required check css.with() #226#230

Merged
github-actions[bot] merged 1 commit intomainfrom
css-with
Aug 19, 2025
Merged

Fix: CSS - More strict required check css.with() #226#230
github-actions[bot] merged 1 commit intomainfrom
css-with

Conversation

@black7375
Copy link
Contributor

@black7375 black7375 commented Aug 19, 2025

Description

More strict type check for required CSSRule type for css.with() API.

Related Issue

Summary by CodeRabbit

  • Refactor
    • Strengthened TypeScript type definitions for CSS rules to enforce non-nullable values for required properties, improving compile-time validation without changing runtime behavior.
  • Tests
    • Expanded and reorganized type-safety tests for CSS configuration, adding checks for required fields and valid properties to ensure clearer TypeScript errors and more robust developer feedback.

Additional context

Checklist

@changeset-bot
Copy link

changeset-bot bot commented Aug 19, 2025

⚠️ No Changeset found

Latest commit: 216f6e1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

Type-level enforcement tightened by making required CSSRule keys non-nullable. Corresponding TypeScript tests for css.with were expanded and reorganized: variable rename, added helper types, additional ts-expect-error cases, and raw() validations. No runtime/production logic changed; no exported APIs beyond the type alias semantics were altered.

Changes

Cohort / File(s) Summary
Type system update
packages/css/src/css/types.ts
Changed RestrictCSSRule so required keys use NonNullable<CSSRule[K]> instead of CSSRule[K]; other type logic unchanged.
Type tests adjustments
packages/css/src/css/index.ts
Renamed local test var to myCss1; added myCss2 helper; expanded ts-expect-error coverage for required/allowed properties; validated raw() with optional radius and enforced required color/background.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

bug

Poem

Thump-thump goes my reviewer heart,
I trim nulls from rules—precision art.
With whiskers twitch, I test and try,
ts-expect-error hops on by.
My CSS now snug and tight—
A rabbit’s joy in types done right. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch css-with

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

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

Triggered from #230 by @​black7375.

Checking if we can fast forward main (60ebee5) to css-with (216f6e1).

Target branch (main):

commit 60ebee56170b3b683b72eb721fdd26bfc46ce338 (HEAD -> main, origin/main)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Wed Jun 11 00:00:00 2025 +0900

    Feat: CSS - `css.with()` API support #226

Pull request (css-with):

commit 216f6e113a5e357d6fd8a0abe7f02f058d2a62d5 (pull_request/css-with)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Mon Jul 21 00:00:00 2025 +0900

    Fix: CSS - More strict required check `css.with()` #226

It is possible to fast forward main (60ebee5) to css-with (216f6e1). If you have write access to the target repository, you can add a comment with /fast-forward to fast forward main to css-with.

Copy link

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/css/src/css/index.ts (2)

355-360: Clarify comments: “values” vs “properties”

The inline comments read like property-level allowances, but they’re actually about value domains.

Apply this diff to improve clarity:

-        color: "red", // Allow all properties
-        background: "blue", // Only some properties are allowed
+        color: "red", // Allow any value for 'color'
+        background: "blue", // Only some values are allowed for 'background'

366-374: Add explicit undefined/null cases to validate NonNullable enforcement

Since required keys marked with true are now NonNullable, add explicit checks for undefined and null to prevent regressions.

Apply this diff to extend coverage:

       // @ts-expect-error: color is required
       myCss1({
         background: "blue"
       });
       // @ts-expect-error: background is required
       myCss1({
         color: "red"
       });
+      // @ts-expect-error: color cannot be undefined when marked as required
+      myCss1({
+        color: undefined,
+        background: "blue"
+      });
+      // @ts-expect-error: color cannot be null when marked as required
+      myCss1({
+        // null isn't a valid CSS value here and is excluded by NonNullable
+        color: null,
+        background: "blue"
+      });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 60ebee5 and 216f6e1.

📒 Files selected for processing (2)
  • packages/css/src/css/index.ts (1 hunks)
  • packages/css/src/css/types.ts (1 hunks)
🔇 Additional comments (4)
packages/css/src/css/types.ts (1)

12-12: NonNullable for required CSSRule values is the right tightening

Using NonNullable<CSSRule[K]> for keys marked with true closes the gap where a required property could still accept undefined/null. This aligns perfectly with the PR goal and keeps user-specified unions (like "blue" | "grey") intact elsewhere.

packages/css/src/css/index.ts (3)

349-354: Good expansion of type-restriction coverage

Defining myCss1 with mixed sentinel booleans and literal unions is a clear, readable way to exercise the RestrictCSSRule behavior for allowed, denied, and required keys.


361-365: LGTM: negative test for disallowed value domain

The ts-expect-error for background: "red" correctly verifies that only "blue" | "grey" are permitted.


375-378: Nice: verifies requiredness without callback path

The myCss2 case is a solid assertion that requiredness is preserved even when no callback is supplied (identity path), and radius remains optional.

@black7375
Copy link
Contributor Author

/fast-forward

@github-actions
Copy link
Contributor

Triggered from #230 (comment) by @​black7375.

Trying to fast forward main (60ebee5) to css-with (216f6e1).

Target branch (main):

commit 60ebee56170b3b683b72eb721fdd26bfc46ce338 (HEAD -> main, origin/main)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Wed Jun 11 00:00:00 2025 +0900

    Feat: CSS - `css.with()` API support #226

Pull request (css-with):

commit 216f6e113a5e357d6fd8a0abe7f02f058d2a62d5 (pull_request/css-with)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Mon Jul 21 00:00:00 2025 +0900

    Fix: CSS - More strict required check `css.with()` #226

Fast forwarding main (60ebee5) to css-with (216f6e1).

$ git push origin 216f6e113a5e357d6fd8a0abe7f02f058d2a62d5:main
To https://github.com/mincho-js/mincho.git
   60ebee5..216f6e1  216f6e113a5e357d6fd8a0abe7f02f058d2a62d5 -> main

@github-actions github-actions bot merged commit 216f6e1 into main Aug 19, 2025
12 checks passed
@github-actions github-actions bot deleted the css-with branch August 19, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant