-
-
Notifications
You must be signed in to change notification settings - Fork 608
feat: use ReadonlyArray in props #574
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
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/react-component/table/3r738ytgi |
Codecov Report
@@ Coverage Diff @@
## master #574 +/- ##
=======================================
Coverage 99.87% 99.87%
=======================================
Files 26 26
Lines 803 803
Branches 224 234 +10
=======================================
Hits 802 802
Misses 1 1
Continue to review full report at Codecov.
|
CI failed. use |
还有 2 个 error 哈~ |
@zombieJ fixed |
src/utils/valueUtil.tsx
Outdated
if (arr === undefined || arr === null) { | ||
return []; | ||
} | ||
|
||
// @ts-expect-error |
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.
不要用 @ts-expect-error
,其实只要处理入口的 readonly 就够了,内部很多 param 没有必要改成 readOnly 的
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.
@zombieJ 内部的也需要一起改,否则就需要进行强制类型转换了。
(顺便一提,这个地方没法写得类型安全,在 ts 4.1.2 是可以写成 function toArray<T>(arr: T | readonly T[]): readonly T[]
通过编译的,但是 4.1.3 undo 了这个 PR)
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.
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.
其实我觉得入口强转一下也 ok,内部其实也不是特别在乎。那就覆盖一下定义吧
@zombieJ 我提一下 antd 的 PR |
Our data types are immutable and we can't use rc-table unless we use
.slice()
to clone data and convert it to mutable array.But the implementation of rc-table does not rely on mutable array, it should be immutable.
So I change the props types of rc-table to immutable array such that I can use
related issue: NG-ZORRO/ng-zorro-antd#6156 (comment)