Skip to content

fix: correct type definitions for ElMessageBox#23518

Merged
Dsaquel merged 3 commits into
element-plus:devfrom
jaa134:dev
Jan 25, 2026
Merged

fix: correct type definitions for ElMessageBox#23518
Dsaquel merged 3 commits into
element-plus:devfrom
jaa134:dev

Conversation

@jaa134
Copy link
Copy Markdown
Contributor

@jaa134 jaa134 commented Jan 23, 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.

What was done?

  • Correct type definitions for return type of ElMessageBoxShortcutMethod. Use union (|) instead of intersection (&) for type definition.

Summary by CodeRabbit

  • New Features
    • Added explicit support for different message box types: prompt, alert, and confirm.
    • Improved message box payload handling for greater flexibility and compatibility with varied inputs.
    • Validators are now optional for message box input.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 23, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR changes the exported type MessageBoxData in the message-box component from an intersection (MessageBoxInputData & Action) to a union (MessageBoxInputData | Action).

Changes

Cohort / File(s) Summary
Type change (message-box)
packages/components/message-box/src/message-box.type.ts
Modified export type MessageBoxData from MessageBoxInputData & Action to `MessageBoxInputData

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through types with a jaunty run,
Swapped an ampersand for unioned fun,
One tiny tweak, the fields set free,
A gentle change from A and B,
Hooray — a cleaner message-box for me.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: correct type definitions for ElMessageBox' directly matches the main change: correcting TypeScript type definitions for ElMessageBox from intersection to union.
Description check ✅ Passed The description includes all checklist items checked, explains what was done (correcting type definitions using union instead of intersection), and confirms following contribution guidelines and target branch requirements.
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 23, 2026

Open in StackBlitz

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

commit: ec7893b

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

🤖 Fix all issues with AI agents
In `@packages/components/message-box/src/message-box.type.ts`:
- Around line 213-226: The type ElMessageBoxShortcutMethod is currently a union
of two callable signatures which allows a function to match only one signature;
change it to an intersection of the two function types so a single function (as
implemented by messageBoxFactory and used by alert/confirm/prompt) exposes both
call signatures. Update the declaration of ElMessageBoxShortcutMethod to use &
between the two function signatures (keeping the same parameter lists and return
type) so the shortcut methods accept both (message, options?, appContext?) and
(message, title, options?, appContext?) forms.

Comment thread packages/components/message-box/src/message-box.type.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 23, 2026

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

@jaa134 jaa134 force-pushed the dev branch 3 times, most recently from faca6df to 6806e62 Compare January 23, 2026 17:35
@jaa134
Copy link
Copy Markdown
Contributor Author

jaa134 commented Jan 23, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Member

@Dsaquel Dsaquel left a comment

Choose a reason for hiding this comment

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

Thanks, can you update only the line concerned please.

@jaa134
Copy link
Copy Markdown
Contributor Author

jaa134 commented Jan 25, 2026

@Dsaquel done! Reverted other changes and updated MR description.

@jaa134 jaa134 requested a review from Dsaquel January 25, 2026 03:00
@Dsaquel Dsaquel merged commit ff08eff into element-plus:dev Jan 25, 2026
14 of 15 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

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