Skip to content

refactor(components): [statistic] use type-based definitions#23452

Merged
rzzf merged 6 commits into
element-plus:devfrom
snowbitx:refactor/use-type-statistic
Jan 19, 2026
Merged

refactor(components): [statistic] use type-based definitions#23452
rzzf merged 6 commits into
element-plus:devfrom
snowbitx:refactor/use-type-statistic

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

  • Refactor
    • Clarified public typings for the Statistic component and introduced a new public props alias (old alias deprecated).
    • Switched the component to typed prop declarations with explicit default values for decimal/group separators, precision, value, and value style to standardize behavior.

✏️ 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 the runtime-exported prop type with an explicit exported TypeScript interface StatisticProps, adds a deprecated StatisticPropsPublic alias using ExtractPublicPropTypes, removes the ExtractPropTypes export/import, and updates the .vue component to use defineProps<StatisticProps>() with withDefaults.

Changes

Cohort / File(s) Summary
Statistic type definitions
packages/components/statistic/src/statistic.ts
Added exported interface StatisticProps; added type StatisticPropsPublic = ExtractPublicPropTypes<typeof statisticProps> (deprecated); removed exported type StatisticProps = ExtractPropTypes<typeof statisticProps> and removed ExtractPropTypes import; kept statisticProps with a deprecation notice.
Statistic component implementation
packages/components/statistic/src/statistic.vue
Switched from import { statisticProps } to import type { StatisticProps }; changed defineProps(statisticProps)withDefaults(defineProps<StatisticProps>(), { decimalSeparator: '.', groupSeparator: ',', precision: 0, value: 0, valueStyle: undefined }).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • keeplearning66

Poem

🐇 I hopped through props and set them right,
New interfaces tucked in tight,
Defaults snug in a tidy row,
Types now guide the props' flow,
A rabbit's nibble — code aglow ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: converting the statistic component to use type-based prop definitions instead of runtime-based ones.
Description check ✅ Passed The description follows the template by checking all required checklist items and includes a reference to the related 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 18, 2026

Open in StackBlitz

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

commit: 09ee3f4

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

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

Comment thread packages/components/statistic/src/statistic.ts Outdated
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/statistic/src/statistic.ts`:
- Around line 21-23: Change the formatter property return type in the
StatisticProps interface from void to string | number so consumers can return
displayable values; locate the formatter declaration (formatter?: (...args:
any[]) => void) in StatisticProps and update its signature to (value: number) =>
string | number (or a compatible generic signature like (...args: any[]) =>
string | number) to match the implementation in statistic.vue where the
formatter result is returned for display.

Comment thread packages/components/statistic/src/statistic.ts Outdated
@rzzf rzzf merged commit 41fee2c into element-plus:dev Jan 19, 2026
17 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@snowbitx Thanks for your contribution! ❤️

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

3 participants