Skip to content

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

@slhsxcmy

Description

@slhsxcmy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions