Conversation
总体概述此次变更修改了 变更内容
代码审查工作量估算🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 🧪 Unit Test Generation v2 is now available!We have significantly improved our unit test generation capabilities. To enable: Add this to your reviews:
finishing_touches:
unit_tests:
enabled: trueTry it out by using the Have feedback? Share your thoughts on our Discord thread! 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 |
next-core
|
||||||||||||||||||||||||||||
| Project |
next-core
|
| Branch Review |
alex/useBrickFunction
|
| Run status |
|
| Run duration | 00m 24s |
| Commit |
|
| Committer | Chén Wénháo |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
17
|
| View all changes introduced in this branch ↗︎ | |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3 #4854 +/- ##
=======================================
Coverage 95.20% 95.20%
=======================================
Files 223 223
Lines 9489 9489
Branches 1821 1821
=======================================
Hits 9034 9034
Misses 334 334
Partials 121 121
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
该 PR 旨在修复“brick 设置了原生属性时出现报错”的问题,通过放宽 wrapBrick / wrapLocalBrick 的泛型约束来避免类型层面的不兼容。
Changes:
- 将
wrapLocalBrick的泛型约束从T extends HTMLElement放宽为T extends Partial<HTMLElement> - 将
wrapBrick的泛型约束从T extends HTMLElement放宽为T extends Partial<HTMLElement> - 调整部分函数重载/实现签名的写法以匹配新的泛型声明
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function wrapLocalBrick< | ||
| T extends Partial<HTMLElement>, | ||
| P, | ||
| E, | ||
| M extends object, | ||
| >( |
There was a problem hiding this comment.
The new generic constraint T extends Partial<HTMLElement> makes almost any object type assignable (since all HTMLElement members are optional), which means ref/event handler generics can now be something that is not actually a DOM element. If the goal is only to relax structural compatibility while still guaranteeing a real element instance, consider constraining T to a DOM base type (e.g. Element/HTMLElement) and introducing a separate type parameter for any “looser” view of the instance, rather than weakening the element constraint to Partial<HTMLElement>.
| export function wrapBrick< | ||
| T extends Partial<HTMLElement>, | ||
| P, | ||
| E, | ||
| M extends object, | ||
| >(BrickName: string, eventsMapping: M): WrappedBrickWithEventsMap<T, P, E, M>; |
There was a problem hiding this comment.
Same concern for wrapBrick: switching T to Partial<HTMLElement> widens the public API so wrapBrick<Foo, P>(...) can compile even when Foo is not a DOM element type, which can make ref typing misleading. If you need to support bricks whose instance types aren’t structurally compatible with HTMLElement, consider a safer bound (e.g. T extends Element) and/or a separate generic for the loose instance view used by callers.
| export function wrapLocalBrick<T extends Partial<HTMLElement>, P>( | ||
| brick: Constructable<T> | string | ||
| ): WrappedBrick<T, P>; |
There was a problem hiding this comment.
This change is intended to fix a typing error scenario, but there’s no regression coverage that would fail before and pass after (e.g. a compile-time usage that previously violated T extends HTMLElement). Consider adding a minimal type-level regression (even just a non-runtime "compiles" usage in the existing Jest TS test file) that exercises a brick instance type including native attributes/properties that previously triggered the error, so the issue doesn’t regress silently.
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat作为提交类型。BREAKING CHANGE: 你的变更说明。新特性:
feat作为提交类型。问题修复:
fix作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore,docs,test等作为提交类型。Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.