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

getValue fails to infer correct type when columnHelper.accessor defined within columnHelper.group #5860

Open
2 tasks done
crcorbett opened this issue Jan 8, 2025 · 0 comments

Comments

@crcorbett
Copy link

crcorbett commented Jan 8, 2025

TanStack Table version

8.20.6

Framework/Library version

React 19.0.0

Describe the bug and the steps to reproduce it

When a column is created using the columnHelper.accessor() utility within a column group columnHelper.group() the type of getValue is not correctly inferred.

CodeSandbox: https://codesandbox.io/p/devbox/funny-bush-lfv773

Example:

type Person = {
  firstName: string
  lastName: string
  age: number
  visits: number
  status: string
  progress: number
}

const defaultData: Person[] = [
  {
    firstName: 'tanner',
    lastName: 'linsley',
    age: 24,
    visits: 100,
    status: 'In Relationship',
    progress: 50,
  },
  {
    firstName: 'tandy',
    lastName: 'miller',
    age: 40,
    visits: 40,
    status: 'Single',
    progress: 80,
  },
  {
    firstName: 'joe',
    lastName: 'dirte',
    age: 45,
    visits: 20,
    status: 'Complicated',
    progress: 10,
  },
]

const columnHelper = createColumnHelper<Person>()

const columns = [
  columnHelper.accessor('firstName', {
    cell: info => info.getValue(),
    footer: info => info.column.id,
  }),
  columnHelper.group({
    id:'group',
    columns:[
      columnHelper.accessor(row => row.lastName, {
        id: 'lastName',
        // Unsafe return of a value of type `any`.
        // eslint[@typescript-eslint/no-unsafe-return](https://typescript-eslint.io/rules/no-unsafe-return)
        // CellContext<Person, any>.getValue: <any>() => any
        cell: info => <i>{info.getValue()}</i>, 
        header: () => <span>Last Name</span>,
        footer: info => info.column.id,
      }),
    ]
  })
]

Potentially related issue: #5065

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/funny-bush-lfv773

Screenshots or Videos (Optional)

No response

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

No, because I do not know how

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

No branches or pull requests

1 participant