Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improved support for generics MenuItemType and MenuItemProps in the Menu component #42240

Merged
merged 5 commits into from
May 10, 2023

Conversation

yangyuanxx
Copy link
Contributor

@yangyuanxx yangyuanxx commented May 9, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

Fix: #36065

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English improved support for generics MenuItemType and MenuItemProps in the Menu component
🇨🇳 Chinese 改进了 Menu 组件对 MenuItemType 和 MenuItemProps 泛型的支持

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at 83dbe46

Refactored Menu and MenuItem components to support custom menu item types and props as generic parameters. This allows users to create and use their own menu item types with additional props and callbacks.

🔍 Walkthrough

🤖 Generated by Copilot at 83dbe46

  • Modify ItemType type alias to support custom menu item types using generic parameter and conditional type (link)
  • Import ItemType and MenuItemType types from useItems hook module to Menu component module (link)
  • Modify CompoundedComponent type alias to support custom props for Menu component using generic parameter and custom type aliases (link)
  • Add GenericComponent interface to extend CompoundedComponent type and override call signature to accept generic props (link)
  • Cast Menu component to GenericComponent type instead of CompoundedComponent type to export generic call signature and subcomponents (link)
  • Modify MenuItem component to support custom props for different menu items using generic parameter and custom type alias (link)

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2023

@yangyuanxx
Copy link
Contributor Author

yangyuanxx commented May 9, 2023

related issue: #36065

@codecov
Copy link

codecov bot commented May 9, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (492dbbe) 100.00% compared to head (7d8c33b) 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##            master    #42240    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          619       618     -1     
  Lines        11048     10539   -509     
  Branches      3079      2879   -200     
==========================================
- Hits         11048     10539   -509     
Impacted Files Coverage Δ
components/menu/hooks/useItems.tsx 100.00% <ø> (ø)
components/menu/index.tsx 100.00% <ø> (ø)
components/form/Form.tsx 100.00% <100.00%> (ø)
components/form/hooks/useFormWarning.ts 100.00% <100.00%> (ø)
components/menu/MenuItem.tsx 100.00% <100.00%> (ø)

... and 23 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@afc163
Copy link
Member

afc163 commented May 9, 2023

Could you add a typing test in components/modal/__tests__/type.test.ts?

@afc163 afc163 merged commit a60d55e into ant-design:master May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow widening of ItemType
2 participants