Skip to content

refactor(components): [check-tag] use type-based definitions#23424

Merged
btea merged 1 commit into
element-plus:devfrom
snowbitx:refactor/use-type-check-tag
Jan 18, 2026
Merged

refactor(components): [check-tag] use type-based definitions#23424
btea merged 1 commit into
element-plus:devfrom
snowbitx:refactor/use-type-check-tag

Conversation

@snowbitx
Copy link
Copy Markdown
Contributor

@snowbitx snowbitx commented Jan 18, 2026

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

ref #23399

Summary by CodeRabbit

  • New Features

    • CheckTag component now defaults to 'primary' type when not explicitly specified.
  • Refactor

    • Enhanced type safety and prop definitions for CheckTag component, improving consistency and developer experience with better type support.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

This PR refactors the check-tag component to introduce a new public CheckTagProps interface and switch from runtime prop definitions to type-based prop interfaces, replacing ExtractPropTypes with ExtractPublicPropTypes for improved type safety.

Changes

Cohort / File(s) Summary
Type-based Props Refactoring
packages/components/check-tag/src/check-tag.ts
Introduces new public CheckTagProps interface with three optional fields (checked, disabled, type). Replaces ExtractPropTypes import with ExtractPublicPropTypes. Updates public type alias to CheckTagPropsPublic with deprecation notice.
Component Props Definition
packages/components/check-tag/src/check-tag.vue
Switches from runtime checkTagProps usage to type-based defineProps<CheckTagProps>() with withDefaults(). Sets default value for type prop to 'primary'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • element-plus/element-plus#23412 — Performs the same code-level refactor switching from runtime prop objects to type-based prop interfaces with ExtractPublicPropTypes and withDefaults.
  • element-plus/element-plus#23400 — Applies the same type-based props refactoring pattern across multiple components.
  • element-plus/element-plus#23403 — Replaces ExtractPropTypes with explicit public interfaces and ExtractPublicPropTypes, updating components to use type-based defineProps<T>() with withDefaults.

Suggested labels

Contribution::Community

Suggested reviewers

  • rzzf
  • keeplearning66

Poem

🐰 A tag that checks, now typed with care,
With props so clear, beyond compare,
From runtime rules to types so bright,
The check-tag hops to syntax's height! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the repository's standard checklist template and lacks specific details about the changes, implementation, or rationale for the refactoring. Add a detailed description of what was changed and why (e.g., explain the switch from ExtractPropTypes to ExtractPublicPropTypes, the new CheckTagProps interface, and the benefits of type-based definitions).
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main refactoring change: converting the check-tag component to use type-based prop definitions instead of the previous approach.
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

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 18, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@23424
npm i https://pkg.pr.new/element-plus/element-plus@23424
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: 7b3a126

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.

Actionable comments posted: 0

Caution

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

⚠️ Outside diff range comments (1)
packages/components/check-tag/src/check-tag.vue (1)

18-29: Runtime type validation is dropped with the new interface.
The deprecated checkTagProps object previously enforced valid type values via a runtime values validator. Switching to defineProps<CheckTagProps>() uses only the TypeScript interface, which provides compile-time safety but removes the runtime warning for invalid values. Consider reusing the deprecated checkTagProps in defineProps until 3.0.0, or add a custom validator if runtime validation is needed.

🧹 Nitpick comments (1)
packages/components/check-tag/src/check-tag.ts (1)

5-25: Keep CheckTagProps and checkTagProps in sync.
There are now two sources of truth (the interface and the runtime props). Consider deriving the interface from checkTagProps (e.g., ExtractPublicPropTypes) or adding a compile-time assertion so they can’t drift.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Playground Preview: https://element-plus.run/?pr=23424
Please comment the example via this playground if needed.

Copy link
Copy Markdown
Member

@keeplearning66 keeplearning66 left a comment

Choose a reason for hiding this comment

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

Thank you!

@btea btea merged commit a2d42d8 into element-plus:dev Jan 18, 2026
20 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@snowbitx Thanks for your contribution! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants