-
-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
统一基础值类型 #49058
Comments
现在 React.Key 里有个 bigint,难受。 |
我升级类型文件之后,看着报红,又决定回退版本了 |
具体问题反馈一下,提供一个重现?这样比较好下手。 |
Hello @guaijie. Please provide a online reproduction by forking codesandbox of antd@5.x or antd@4.x, or provide a minimal GitHub repository. Issues labeled by 你好 @guaijie,我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击这里创建一个 antd@5.x 或 antd@4.x 的 codesandbox,或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。 |
Start a new pull request in StackBlitz Codeflow. |
antd v4? |
fix v5 |
@crazyair 是否要对所有支持 number 数据类型的组件都让其支持 bigint 类型? |
不是给类型增加什么类型,而是用 T |
|
我懂你的意思,我想表述的意思是否对所有支持 number 数据类型的组件都改成泛型的形式 像这种的话,只支持 number 无可厚非,当然也可以是 bigint , 但改成 T 没有意义 |
这样就属于组件定义的范畴了,如果定死数字类型也不是不可以 |
当然,ValueType = number | bigint | string 这种类型约束,个人感觉更好。any 意味着任意类型 <InputNumber<number[]> /> 显然不合理 |
|
我知道,但也意味着 value 可以传递任何值,因为它已经不受约束了 <InputNumber value={[1]}, ts 不会报任何错误。但事实是,组件内部应该会报错(当然,我并没有看源码,所以并不清楚是否真的报错) |
报不报错,其实不是要类型来兜底,有的项目还不是 ts 呢? |
@crazyair 当然,只是你们很多地方都有进行类型约束,比如 select options , option.value 等,你们这样的目的,也是想在使用时就提醒到用户可以支持的类型有哪些。 |
InputNumber 目前支持不了 bigint,不只是类型的问题,组件能力还不支持。 |
Reproduction link
复现链接地址
Steps to reproduce
@types/react 的 Key 类型修改为 type Key = number | string | bigint
在 antd 中有些组件的值使用的是 React.Key
有的组件值使用的是 string | number
在过去这并没有什么问题,但在最新的版本中因 Key 的类型修改导致在各个组件中进行值传递时会导致类型报错
What is expected?
统一基础值类型,要么都为 number | string(或再联合其他类型) 类型,要么都为 React.Key 的类型(或再联合其他类型)
What is actually happening?
no response
The text was updated successfully, but these errors were encountered: