Skip to content
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

The type of the 'record' argument of render func in the 'columns' props of the table is showing up as any. #48960

Closed
minjinso opened this issue May 17, 2024 · 5 comments
Labels

Comments

@minjinso
Copy link

minjinso commented May 17, 2024

Reproduction link

https://codesandbox.io/p/sandbox/antd-reproduction-template-forked-95c7mg?file=%2FApp.tsx%3A27%2C22

Steps to reproduce

  1. Make custom table component using Antd Table. (with generic for record type)
  2. import custom table.
  3. Assigning dataSource, columns props etc.
  4. Writing item object(ColumnsType) in columns props array.

What is expected?

Defining "render" method of column, the type of record should be E (that I assigned).

What is actually happening?

The RecordType is any, so ts error(7044) occurred.

Environment Info
antd 5.16.0
React 18.2.79
System macos
Browser chrome

It works as I expected when I downgrade the antd version to 5.15.4.

Through debugging, it was confirmed that this issue occurs because the RecordType = any statement was added to the TableProps of rc-table(v7.45) starting from antd version 5.16.0.

@minjinso minjinso changed the title The type of the 'record' argument in the 'columns' props of the table is showing up as any. The type of the 'record' argument of render func in the 'columns' props of the table is showing up as any. May 17, 2024
@zombieJ zombieJ added 🤔 Need Reproduce We cannot reproduce your problem and removed unconfirmed labels May 17, 2024
Copy link
Contributor

Hello @minjinso. 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 Need Reproduce will be closed if no activities in 3 days.

你好 @minjinso,我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击这里创建一个 antd@5.xantd@4.x 的 codesandbox,或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

什么是最小化重现,为什么这是必需的?

@zombieJ
Copy link
Member

zombieJ commented May 22, 2024

--  <CustomTable
++  <CustomTable<Temp>

When you wrap with HOC, ts at least need a case for infer the generic type. Your HOC component do not have it so can add on component directly.

@zombieJ zombieJ added Usage and removed 🤔 Need Reproduce We cannot reproduce your problem labels May 22, 2024
Copy link
Contributor

Hello @minjinso, we use GitHub issues to trace bugs or discuss plans of Ant Design. So, please don't ask usage questions here. You can try to open a new discussion in antd discussions, select Q&A to ask questions, also can ask questions on Stack Overflow or Segment Fault, then apply tag antd and react to your question.

你好 @minjinso,Ant Design Issue 板块是用于 bug 反馈与需求讨论的地方。请勿询问如何使用的问题,你可以试着在 antd discussions 新开一个 discussion,选择 Q&A 类别进行提问,也可以在 Stack Overflow 或者 Segment Fault 中提问(记得添加 antdreact 标签哦~)。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
@crazyair
Copy link
Member

image

@crazyair
Copy link
Member

image

你这个类型可以实现利用 dataIndex 推导出 value 类型,但是如果 dataIndex 是数组,便无法使用了。目前还没想好到好的办法推导出 value 类型,我会持续关注 typescript 功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants