-
Notifications
You must be signed in to change notification settings - Fork 134
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
type: narrow onChange argument to React.Key[] #352
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次更改涉及 Changes
Poem
Tip New features:
Notes:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/Collapse.tsx (1 hunks)
- src/interface.ts (1 hunks)
Additional comments not posted (2)
src/interface.ts (1)
27-27
: 类型定义已正确更新。
onChange
属性的类型已从React.Key | React.Key[]
更改为React.Key[]
,这有助于提高类型安全性。请确保所有使用此接口的组件都已更新,以传递键数组。运行以下脚本以验证整个代码库中
onChange
的使用情况:Verification successful
类型定义更新已在代码库中正确实施。
onChange
属性的类型更新为React.Key[]
已在主要实现和测试文件中得到正确应用。请确保文档示例也反映了此更新。
src/Collapse.tsx
中的onChange
使用符合新签名。tests/index.spec.tsx
中的测试用例验证了新签名的正确性。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:验证所有 `onChange` 函数调用都匹配新的签名。 # 测试:搜索函数使用情况。预期:只有新签名的出现。 rg --type typescript -A 5 $'onChange'Length of output: 71
Script:
#!/bin/bash # 描述:验证所有 `onChange` 函数调用都匹配新的签名。 # 测试:搜索函数使用情况。预期:只有新签名的出现。 rg --glob '*.ts' --glob '*.tsx' -A 5 $'onChange'Length of output: 7771
src/Collapse.tsx (1)
41-41
: 类型断言已正确添加。在
useMergedState
钩子中,onChange
回调现在显式地将值转换为React.Key[]
,这与接口的更改保持一致,确保类型安全性。请通过单元测试验证此更改不会引入任何意外的副作用。运行以下脚本以验证
onChange
回调的功能:Verification successful
类型断言已正确添加且通过测试验证。
在
src/Collapse.tsx
中对onChange
回调的更改已通过现有的单元测试验证。这些测试确保onChange
回调按预期工作,并且类型断言不会引入任何意外的副作用。
- 相关测试文件:
tests/index.spec.tsx
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:验证 `onChange` 回调的功能是否按预期工作。 # 测试:搜索相关的单元测试。预期:找到并运行测试以确认功能。 rg --type typescript -A 5 $'onChange'Length of output: 71
Script:
#!/bin/bash # 描述:验证 `onChange` 回调的功能是否按预期工作。 # 测试:搜索相关的单元测试。预期:找到并运行测试以确认功能。 rg --type ts -A 5 $'onChange'Length of output: 7752
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #352 +/- ##
=======================================
Coverage 99.13% 99.13%
=======================================
Files 5 5
Lines 116 116
Branches 42 42
=======================================
Hits 115 115
Misses 1 1 ☔ View full report in Codecov by Sentry. |
ant-design/ant-design#50754
Summary by CodeRabbit
Collapse
组件的onChange
回调,增强了类型安全性,确保回调接收一个键数组。CollapseProps
接口中的onChange
属性,使其仅接受键数组,确保一致性和清晰性。