Skip to content

refactor(components): [form/form-item] use type-based definitions#23483

Merged
rzzf merged 4 commits into
element-plus:devfrom
snowbitx:refactor/use-type-form
Jan 20, 2026
Merged

refactor(components): [form/form-item] use type-based definitions#23483
rzzf merged 4 commits into
element-plus:devfrom
snowbitx:refactor/use-type-form

Conversation

@snowbitx
Copy link
Copy Markdown
Contributor

@snowbitx snowbitx commented Jan 19, 2026

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

Summary by CodeRabbit

  • Refactor
    • Converted Form and FormItem public prop typings to explicit TypeScript interfaces (FormProps, FormMetaProps, FormItemProps) with deprecation notices for prior types.
    • Switched components to typed props with defaults for several fields (e.g., labelPosition, showMessage, required, inlineMessage, labelWidth).
    • Preserved runtime behavior and backward compatibility while clarifying exported prop shapes.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Runtime prop schemas for Form and FormItem were replaced with explicit exported TypeScript interfaces (FormProps, FormMetaProps, FormItemProps). Components now use typed defineProps() wrapped with withDefaults for defaults; deprecated ExtractPropTypes-based exports were retained as annotated aliases.

Changes

Cohort / File(s) Summary
Form core types
packages/components/form/src/form.ts
Added exported interfaces FormProps and FormMetaProps (includes fields like size, model, rules, labelPosition, inlineMessage, scrollIntoViewOptions); removed exported ExtractPropTypes aliases; added ComponentSize import, ExtractPublicPropTypes usage, and deprecation notices for old type exports.
FormItem types
packages/components/form/src/form-item.ts
Added exported interface FormItemProps (label, labelWidth, labelPosition, prop, required, rules, error, validateStatus, for, inlineMessage, showMessage, size); removed ExtractPropTypes-based export; added ComponentSize import and public alias via ExtractPublicPropTypes with deprecation note.
Vue components (props usage)
packages/components/form/src/form.vue, packages/components/form/src/form-item.vue
Switched from runtime prop schemas (formProps/formItemProps) to defineProps<FormProps>() / defineProps<FormItemProps>() wrapped with withDefaults(...) to supply defaults (e.g., labelPosition, showMessage, required, inlineMessage); updated imports to use new interfaces.
Public API surface
packages/components/form/src/...
Public prop typings changed from ExtractPropTypes-derived exports to explicit interfaces; ExtractPublicPropTypes aliases preserved and annotated as deprecated.

Sequence Diagram(s)

(omitted — changes are type/interface and component prop typing updates without new multi-component control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • rzzf
  • btea
  • keeplearning66

Poem

🐰 Hopping through props with a TypeScript tune,

Interfaces sprout beneath the moon.
withDefaults sets defaults nice and neat,
Deprecated echoes take their seat.
A tidy hop — the form feels complete.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: converting the form and form-item components from schema-based prop definitions to type-based definitions.
Description check ✅ Passed The description follows the template with all checklist items completed, contributing guide confirmed, target branch verified as dev, and references issue #23399.
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 19, 2026

Open in StackBlitz

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

commit: 2d7816a

@github-actions
Copy link
Copy Markdown
Contributor

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

@Dsaquel Dsaquel changed the title refactor(components): [form] use type-based definitions refactor(components): [form/form-item] use type-based definitions Jan 19, 2026
Comment thread packages/components/form/src/form-item.ts
Comment thread packages/components/form/src/form-item.ts
Comment thread packages/components/form/src/form-item.ts Outdated
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!

@rzzf rzzf merged commit 5ea2563 into element-plus:dev Jan 20, 2026
15 of 16 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@snowbitx Thanks for your contribution! ❤️

lw56777 pushed a commit to lw56777/element-plus that referenced this pull request Jan 27, 2026
…ement-plus#23483)

* refactor(components): [form] use type-based definitions

* fix: add export

* fix: add type
@element-bot element-bot mentioned this pull request Jan 30, 2026
3 tasks
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.

4 participants