Skip to content

refactor(components): [descriptions] use type-based definitions#23434

Merged
btea merged 3 commits into
element-plus:devfrom
SevenDreamYang:use-type-based-definitions-descriptions
Jan 18, 2026
Merged

refactor(components): [descriptions] use type-based definitions#23434
btea merged 3 commits into
element-plus:devfrom
SevenDreamYang:use-type-based-definitions-descriptions

Conversation

@SevenDreamYang
Copy link
Copy Markdown
Contributor

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

Other Notes

descriptionitem was not refactored because of defineComponent

Summary by CodeRabbit

  • Refactor

    • Converted runtime prop definitions to exported typed interfaces and switched components to use typed props with explicit default values for common options, improving type safety and consistency.
    • Added new public interfaces for instances and row data shapes.
  • Deprecations

    • Marked legacy prop-definition aliases as deprecated and advised migration to the new public interfaces.

✏️ 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

Replaces runtime prop objects with explicit TypeScript prop interfaces for Descriptions and DescriptionsRow, adds exported interfaces DescriptionProps and DescriptionsRowProps, introduces DescriptionPropsPublic and DescriptionInstance, and switches components to withDefaults(defineProps<...>(), ...) with default values.

Changes

Cohort / File(s) Change Summary
Descriptions Type Definition
packages/components/descriptions/src/description.ts
Added exported DescriptionProps interface (border, column, direction, size, title, extra, labelWidth) and DescriptionPropsPublic; removed the old ExtractPropTypes alias, added DescriptionInstance type, kept descriptionProps runtime object with deprecation note.
Descriptions Component
packages/components/descriptions/src/description.vue
Replaced runtime import with import type { DescriptionProps }; changed defineProps(descriptionProps)withDefaults(defineProps\<DescriptionProps\>(), { column: 3, direction: 'horizontal', title: '', extra: '' }).
Descriptions Row Type Definition
packages/components/descriptions/src/descriptions-row.ts
Added exported DescriptionsRowProps interface (row?: DescriptionItemVNode[]) and deprecation comment; retained existing descriptionsRowProps.
Descriptions Row Component
packages/components/descriptions/src/descriptions-row.vue
Replaced runtime import with import type { DescriptionsRowProps }; changed defineProps(descriptionsRowProps)withDefaults(defineProps\<DescriptionsRowProps\>(), { row: () => [] }).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • btea
  • keeplearning66

Poem

🐇 I hopped through props both old and new,
Types stitched tidy, defaults snug too,
Deprecated whispers softly fade,
Interfaces laid and not afraid,
Tiny rabbit cheers — refactor hooray! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: refactoring the descriptions component to use type-based prop definitions instead of runtime object definitions.
Description check ✅ Passed The PR description includes the contributor checklist template and provides context (issue reference #23399 and an explanatory note about descriptionitem), though it lacks a detailed explanation of the changes made.
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@23434
npm i https://pkg.pr.new/element-plus/element-plus@23434
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: c9dd7dc

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/descriptions/src/description.vue`:
- Around line 36-52: The change sets a default empty string for labelWidth in
the withDefaults call, which alters runtime behavior by turning previously
undefined labelWidth into ''—remove labelWidth from the defaults object so
defineProps<DescriptionProps>() retains undefined when not provided; update the
withDefaults/defaults block referencing props and DescriptionProps (and ensure
any consumers checking labelWidth === undefined still work).

Comment thread packages/components/descriptions/src/description.vue
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

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

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

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