ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
92.36k stars 49.58k forks source link

fix: fix cascader type #48879

Closed crazyair closed 5 months ago

crazyair commented 5 months ago

中文版模板 / Chinese template

🤔 This is a ...

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Fix the issue of redundant generics in Cascader
🇨🇳 Chinese 修复 Cascader 多余泛型问题

☑️ Self-Check before Merge

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

stackblitz[bot] commented 5 months ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

github-actions[bot] commented 5 months ago

👁 Visual Regression Report for PR #48879 Passed ✅

🎯 Target branch: master (470e8a8e0a269bbe28b139df346bf1081873e0d5) 📖 View Full Report ↗︎

🎊 Congrats! No visual-regression diff found.

github-actions[bot] commented 5 months ago

Preview is ready

github-actions[bot] commented 5 months ago

size-limit report 📦

Path Size
./dist/antd.min.js 337.63 KB
./dist/antd-with-locales.min.js 385.62 KB
codesandbox-ci[bot] commented 5 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (c656603) to head (20dbe46). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #48879 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 746 746 Lines 12994 12997 +3 Branches 3411 3412 +1 ========================================= + Hits 12994 12997 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

afc163 commented 5 months ago

原始问题是啥

crazyair commented 5 months ago

原始问题是啥

如果吧 multiple 类型放到泛型上,如下这种使用,无法自动切换是否 multiple,rc-cascader 写3个泛型是因为,checkable 支持 ReactNode,而 antd 的 Cascader 的 multiple 只是 boolean 类型,所以可以精简泛型

const list: { props: CascaderType }[] = [
      { props: { multiple: true, onChange: (value) => value } },
      { props: { onChange: (value) => value } },
];

如果用 CascaderProps 会报类型错误

image

crazyair commented 5 months ago

image

加上非必填就不行了。。。