refactor(components): [link] use type-based definitions#23411
Conversation
📝 WalkthroughWalkthroughIntroduces a new exported TypeScript interface Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/components/link/src/link.vue`:
- Around line 23-35: The change replaced runtime prop validation by switching to
defineProps<LinkProps>() (removing buildProps/linkProps and iconPropType
validators), which loses enum/value/prop-type runtime warnings; to fix, restore
runtime validation by reintroducing buildProps-based prop definitions (or add
explicit runtime checks) for the type and underline enums and the icon prop
before using them—update the component to use the original linkProps/buildProps
or validate inside setup using the same validators so invalid values trigger
runtime warnings while keeping the TypeScript types; reference the symbols
defineProps<LinkProps>(), linkProps/buildProps, iconPropType, and any usage of
type/underline in the component to locate where to add the checks.
🧹 Nitpick comments (1)
packages/components/link/src/link.ts (1)
3-33: Guard against drift betweenLinkPropsandlinkProps.Now that the public interface and the runtime props are defined separately, it’s easy for them to diverge over time. Consider a lightweight compile‑time check or shared source to keep them aligned.
|
🧪 Playground Preview: https://element-plus.run/?pr=23411 |
Co-authored-by: rzzf <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/components/link/src/link.ts`:
- Around line 40-42: The deprecation JSDoc is ambiguous; update the comment near
the deprecated symbol (the JSDoc block currently saying "Removed after 3.0.0")
to a clear statement such as "Deprecated since X.Y.Z; will be removed in 3.0.0.
Use `LinkProps` instead." Do the same for the second JSDoc occurrence (lines
referencing the same deprecated type around the 83-86 area), and ensure the
deprecated tag and replacement (`LinkProps`) are present and consistent.
🧹 Nitpick comments (1)
packages/components/link/src/link.ts (1)
3-38: Reduce drift betweenLinkPropsandlinkPropsliterals.The literal unions in
LinkPropsduplicate thevaluesarrays inlinkProps, so adding a new type/underline option requires two edits. Consider extracting sharedconstarrays and deriving both the union types andvaluesfrom them to keep a single source of truth.♻️ Suggested refactor
+const linkTypes = ['primary', 'success', 'warning', 'info', 'danger', 'default'] as const +const linkUnderlineValues = [true, false, 'always', 'never', 'hover'] as const +type LinkType = typeof linkTypes[number] +type LinkUnderline = typeof linkUnderlineValues[number] + export interface LinkProps { /** * `@description` type */ - type?: 'primary' | 'success' | 'warning' | 'info' | 'danger' | 'default' + type?: LinkType /** * `@description` when underlines should appear */ - underline?: boolean | 'always' | 'never' | 'hover' + underline?: LinkUnderline ... } export const linkProps = buildProps({ /** * `@description` type */ type: { type: String, - values: ['primary', 'success', 'warning', 'info', 'danger', 'default'], + values: linkTypes, default: undefined, }, /** * `@description` when underlines should appear */ underline: { type: [Boolean, String], - values: [true, false, 'always', 'never', 'hover'], + values: linkUnderlineValues, default: undefined, },The project uses TypeScript 5.5.4, which fully supports
as constassertions and indexed-access types, so this refactor is viable.
|
@Lensiq Thanks for your contribution! ❤️ |

Please make sure these boxes are checked before submitting your PR, thank you!
devbranch.Summary by CodeRabbit
Refactor
Deprecated
✏️ Tip: You can customize this high-level summary in your review settings.