-
-
Notifications
You must be signed in to change notification settings - Fork 217
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: dev and site support React 19 #432
Conversation
WalkthroughThis pull request updates the version of the Changes
🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
📝 Walkthrough变更概述步骤说明该拉取请求主要更新了 变更
可能相关的拉取请求
目标与问题的评估
兔子庆祝诗
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 (
|
Bundle ReportChanges will decrease total bundle size by 614 bytes (-0.39%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@types/lodash@4.17.13, npm/typescript@5.7.2 |
Deploying ant-design-x with Cloudflare Pages
|
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
🧹 Nitpick comments (3)
.dumi/theme/common/PrevAndNext.tsx (2)
144-144
: 建议:使用更具体的类型替代 ReactElement。目前将类型指定为 ReactElement 会放宽对组件标签属性的校验,可能导致类型安全性降低。若已知要传递的属性结构,建议使用更精确的泛型参数来增强可读性与可靠性。
148-148
: 相同问题:请考虑提升类型安全性。与上一段相同,应尽可能避免使用 ReactElement 这种宽泛的类型声明。若后续需扩展该元素,可以使用更具体的类型来确保编译期校验。
.dumi/theme/common/ComponentChangelog/ComponentChangelog.tsx (1)
309-309
: 同类类型注释:避免使用 React.ReactElement。对于需要 clone 的子元素,若能够在内部明确属性结构,可使用更具体的泛型声明,以便在编译时捕捉到潜在的类型错误并提升可维护性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.dumi/components/SemanticPreview.tsx
(1 hunks).dumi/theme/common/ComponentChangelog/ComponentChangelog.tsx
(1 hunks).dumi/theme/common/PrevAndNext.tsx
(1 hunks).dumi/theme/layouts/DocLayout/index.tsx
(2 hunks)components/attachments/index.tsx
(1 hunks)components/sender/index.tsx
(2 hunks)components/sender/interface.ts
(0 hunks)components/suggestion/interface.ts
(0 hunks)tests/utils.tsx
(1 hunks)
💤 Files with no reviewable changes (2)
- components/suggestion/interface.ts
- components/sender/interface.ts
✅ Files skipped from review due to trivial changes (1)
- components/attachments/index.tsx
🔇 Additional comments (6)
tests/utils.tsx (1)
35-35
: 将返回类型更改为可为 null 有助于提升类型安全性。
此处将 React.RefObject<T>
改为 React.RefObject<T | null>
可避免在对 result.current
执行后续操作时出现类型错误,更好地反映真实的引用状态。
.dumi/theme/layouts/DocLayout/index.tsx (1)
Line range hint 38-59
: 为计时器使用 useRef(null)
并在清理时进行空值检查是更安全的做法。
useRef(null)
能提供更明确的初始值,避免在清除计时器时可能出现的空引用错误。在 return 中加入空值检查也能防止 clearTimeout
在 timerRef.current
不存在时抛出异常。
.dumi/components/SemanticPreview.tsx (1)
106-106
: 在 timerRef
中使用空值初始化有助于避免潜在的引用错误。
timerRef
初始化为 null
并在副作用清理函数中执行空值检查,有效防止了在 timerRef.current
尚未赋值时调用 clearTimeout
导致的可能问题。
components/sender/index.tsx (3)
20-21
: 定义提交类型使逻辑更加清晰
在这里添加 SubmitType
类型,有助于在业务层面上明确区分不同提交方式,代码可读性和可维护性得到提升。
26-26
: 替换自定义组件类型为 React.ComponentType
将 CustomizeComponent<TextareaProps>
更改为 React.ComponentType<TextareaProps>
对齐了常规的 React 组件定义方式,有助于减少类型歧义并与社区习惯保持一致。
84-85
: 统一 getComponent 函数返回类型
将 defaultComponent
与返回值统一为 React.ComponentType<T>
,使组件类型更具扩展性,兼容更多组件使用场景。
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #432 +/- ##
=======================================
Coverage 91.45% 91.45%
=======================================
Files 67 67
Lines 1462 1462
Branches 385 370 -15
=======================================
Hits 1337 1337
Misses 125 125 ☔ View full report in Codecov by Sentry. |
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
🧹 Nitpick comments (1)
tests/shared/demoTest.tsx (1)
90-94
: 打印错误信息可提升调试效率,但需注意日志量。在批量测试时,
console.log
可能输出大量信息,建议后续考虑使用更精确的日志监控或条件式打印,避免过多干扰。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
components/attachments/__tests__/__snapshots__/demo-extend.test.ts.snap
is excluded by!**/*.snap
components/attachments/__tests__/__snapshots__/demo.test.tsx.snap
is excluded by!**/*.snap
components/bubble/__tests__/__snapshots__/demo.test.ts.snap
is excluded by!**/*.snap
components/sender/__tests__/__snapshots__/demo-extend.test.ts.snap
is excluded by!**/*.snap
components/suggestion/__tests__/__snapshots__/demo-extend.test.ts.snap
is excluded by!**/*.snap
components/welcome/__tests__/__snapshots__/demo.test.ts.snap
is excluded by!**/*.snap
📒 Files selected for processing (3)
components/x-request/__tests__/demo.test.ts
(1 hunks)components/x-stream/__tests__/demo.test.ts
(1 hunks)tests/shared/demoTest.tsx
(5 hunks)
✅ Files skipped from review due to trivial changes (2)
- components/x-stream/tests/demo.test.ts
- components/x-request/tests/demo.test.ts
🔇 Additional comments (9)
tests/shared/demoTest.tsx (9)
6-6
: 导入 React 的方式可接受。
此处只是简单引入 React
,没有发现问题。
29-29
: 重命名函数符合语义。
baseText
改为 baseTest
更加贴合实际功能,是合理的命名更新。
35-35
: 拼接路径更统一。
通过 file.split(path.sep).join('/')
将不同操作系统的路径分隔符统一为 /
,有助于在多平台环境下保持一致性,没有问题。
38-38
: 条件判断逻辑可读性良好。
通过判断 options.skip
来决定是否跳过测试,逻辑清晰且可维护。
44-44
: 测试语句信息完善。
测试名称可读性高,可帮助快速定位具体用例。对测试结果的可追溯性有帮助。
53-53
: 动态引入 Demo 需要注意错误处理。
这里使用 require
动态载入可以灵活处理 Demo 文件。若文件路径不正确或导出有误时,可能造成运行时错误。建议在后续如发生异常时,进一步捕获并提示相关信息。
109-109
: 在扩展测试时强制注入上下文。
调用 baseTest(true, ...)
以注入 TriggerMockContext
,可方便对弹窗类组件的测试;无明显问题。
116-116
: 默认测试逻辑良好。
这里选择 baseTest(false, ...)
测试常规情况,保证覆盖面足够全面。
120-135
: kebab-case 检查与根属性测试增强了测试完善度。
- 测试组件名与路径是否一致,可避免因命名约定不符导致的文件查找异常。
rootPropsTest
可验证根元素特性,提升组件可插拔性与一致性。
以上逻辑非常实用,建议保留。
之前的基线版本有问题,所以 Size Limit 会挂掉。该 CI 暂时不用管。 |
本 PR 做了几件事情:
useXAgent
和useXChat
进行更正fix: #427
fix: #426
fix: #425
fix: #422
Summary by CodeRabbit
Summary by CodeRabbit
@petercatai/assistant
依赖版本从^2.0.5
升级到^2.0.10
dumi
依赖版本从^2.4.10
升级到^2.4.17
react
和react-dom
依赖版本从^18.3.1
升级到^19.0.0
@ant-design/v5-patch-for-react-19
,版本为^1.0.3
SemanticPreview
组件中的timerRef
初始化为null
,提高类型安全性。ComponentChangelog
组件中的cloneElement
方法参数类型更新为React.ReactElement<any>
,增强类型安全性。PrevAndNext
组件中的React.cloneElement
调用参数类型更新为React.ReactElement<any>
,扩大类型接受范围。DocLayout
组件中对timerRef
的处理和清理函数进行了改进,增强生命周期管理的安全性。Sender
组件中的类型定义和接口进行了简化和清晰化。components/sender/interface.ts
和components/suggestion/interface.ts
文件,移除了相关类型定义。renderHook
函数返回类型,增强类型安全性。baseText
为baseTest
,保持功能不变。use-x-agent
和use-x-chat
组件的测试用例。components/index.ts
中的导出命名规范,采用了 kebab-case。