Skip to content

improvement(components): [select] improve emits type#24074

Merged
btea merged 3 commits into
devfrom
improvement/select-emits-type
Apr 22, 2026
Merged

improvement(components): [select] improve emits type#24074
btea merged 3 commits into
devfrom
improvement/select-emits-type

Conversation

@rzzf
Copy link
Copy Markdown
Member

@rzzf rzzf commented Apr 16, 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.

Before

image

After

image

Removing any from the update:modelValue and change events requires generic components, and the current change will not affect existing code.

Summary by CodeRabbit

  • Refactor
    • Reorganized Select component internals: event emission and prop wiring centralized for cleaner structure.
    • Relaxed emitted-value handling to accept a broader range of values, improving compatibility with varied usage scenarios.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

select.vue now imports selectProps and selectEmits from the select module instead of defining props/emits inline; select.ts widens the runtime emit handler types for UPDATE_MODEL_EVENT and CHANGE_EVENT to accept SelectProps['modelValue'] | any.

Changes

Cohort / File(s) Summary
Select SFC update
packages/components/select/src/select.vue
Replaced inline emits array and direct event constant imports with selectEmits and selectProps imports from the select module; component now uses emits: selectEmits.
Select emits typings
packages/components/select/src/select.ts
Changed emit handler parameter types for UPDATE_MODEL_EVENT and CHANGE_EVENT from SelectProps['modelValue'] to `SelectProps['modelValue']

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Needs Review

Suggested reviewers

  • btea
  • Dsaquel
  • keeplearning66

Poem

🐰 I nibble at emits and props anew,
Hopping from inline to a single view.
Types widened so values can roam free,
A cleaner hop across the codebase tree. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description lacks substantive technical explanation. It contains only a checklist template and visual comparisons without textual details about the motivation, implementation approach, or rationale for the type signature changes. Add a clear written explanation of why the type changes are necessary, what problem they solve, and why using SelectProps['modelValue'] | any is the chosen solution over making the component generic.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: improving the type definitions for the select component's emits, which is reflected in both file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 improvement/select-emits-type

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 Apr 16, 2026

Open in StackBlitz

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

commit: 810de73

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

Size Change: -142 B (-0.01%)

Total Size: 1.47 MB

📦 View Changed
Filename Size Change
dist/element-plus/dist/index.full.js 434 kB -41 B (-0.01%)
dist/element-plus/dist/index.full.min.js 287 kB -27 B (-0.01%)
dist/element-plus/dist/index.full.min.mjs 280 kB -29 B (-0.01%)
dist/element-plus/dist/index.full.mjs 425 kB -45 B (-0.01%)
ℹ️ View Unchanged
Filename Size
dist/element-plus/dist/index.css 47.3 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 86.1% 18383 / 21349
🔵 Statements 84.97% 19245 / 22649
🔵 Functions 84.51% 4901 / 5799
🔵 Branches 75.55% 10687 / 14145
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/components/select/src/select.ts 100% 100% 100% 100%
packages/components/select/src/select.vue 87.71% 81.43% 81.48% 88.28% 401, 403-407, 536, 571, 7, 152, 203-205, 267, 309-311
Generated in workflow #2505 for commit 810de73 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

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

@rzzf rzzf marked this pull request as draft April 16, 2026 03:57
@rzzf
Copy link
Copy Markdown
Member Author

rzzf commented Apr 16, 2026

might be necessary to refactor it into a generic component to fully resolve the type error.

https://github.com/element-plus/element-plus/actions/runs/24491039934/job/71575920616?pr=24074

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@rzzf rzzf marked this pull request as ready for review April 16, 2026 05:47
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/components/select/src/select.ts`:
- Around line 329-331: The emit validators for UPDATE_MODEL_EVENT and
CHANGE_EVENT currently use "SelectProps['modelValue'] | any" which collapses to
any; update these validators to the concrete emitted types instead — replace
"SelectProps['modelValue'] | any" with the actual payload types used in
useSelect.ts (e.g. OptionValue | OptionValue[] or the specific union/type
exported there) so the validators preserve type safety for emits; ensure the
validators reference the OptionValue type (or the exported type from useSelect)
and keep the validator signature (val: OptionValue | OptionValue[] ) => true for
both UPDATE_MODEL_EVENT and CHANGE_EVENT.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf614858-8a8b-40a1-afcb-bc3b3d53ff6b

📥 Commits

Reviewing files that changed from the base of the PR and between 19f6455 and 2b50f39.

📒 Files selected for processing (1)
  • packages/components/select/src/select.ts

Comment thread packages/components/select/src/select.ts
@btea btea added the conflict pending need to resolve conflicts label Apr 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

@rzzf This PR has conflicts, please resolve them.

@github-actions github-actions Bot removed the conflict pending need to resolve conflicts label Apr 21, 2026
@btea btea merged commit 21b2d58 into dev Apr 22, 2026
18 of 19 checks passed
@btea btea deleted the improvement/select-emits-type branch April 22, 2026 02:22
@github-actions
Copy link
Copy Markdown
Contributor

@rzzf Thanks for your contribution! ❤️

ZacharyBear pushed a commit to ZacharyBear/element-plus that referenced this pull request Apr 22, 2026
)

* improvement(components): [select] improve emits type

* chore: update
@element-bot element-bot mentioned this pull request May 8, 2026
3 tasks
btea added a commit that referenced this pull request May 8, 2026