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

Columns created by columnHelper.accessor doesn't know accessorFn or accessorKey #5423

Closed
2 tasks done
slhsxcmy opened this issue Mar 20, 2024 · 0 comments · Fixed by #5424
Closed
2 tasks done

Columns created by columnHelper.accessor doesn't know accessorFn or accessorKey #5423

slhsxcmy opened this issue Mar 20, 2024 · 0 comments · Fixed by #5424

Comments

@slhsxcmy
Copy link
Contributor

slhsxcmy commented Mar 20, 2024

TanStack Table version

8.14.0

Framework/Library version

18

Describe the bug and the steps to reproduce it

Columns created by columnHelper.accessor has type ColumnDef, which is a union of AccessorColumnDef, DisplayColumnDef, and GroupColumnDef. As a result, they don't know that the accessorFn or accessorKey property exists.

Typing them as narrower types like AccessorFnColumnDef or AccessorKeyColumnDef would allow access to these properties. This is helpful for our current use case where we want to directly call the accessorFn on fake data in unit tests.

Example at the bottom of TS Playground

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

See above

Screenshots or Videos (Optional)

Screenshot 2024-03-19 at 7 52 12 PM

Do you intend to try to help solve this bug with your own PR?

Yes, I am also opening a PR that solves the problem along side this issue

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant