Skip to content

DataTable: Incorrect typing for groupRowsBy (and/or incomplete doc) #8316

@clapointe

Description

@clapointe

Describe the bug

Summary: I'm using a DataTable with grouped rows, it's working fine but eslint is giving an error.


In the DataTable component, the groupRowsBy property is defined as such:

    /**
     * One or more field names to use in row grouping.
     */
    groupRowsBy?: ((field: NoInfer<T>) => object) | (keyof T)[] | keyof T | undefined;

What is this "object" in the function return value supposed to be?
The doc doesn't give an example other than passing a field name in the groupRowsBy property, and in the API it just says keyof T | Function | (keyof T)[]

https://primevue.org/datatable/#api.datatable.props.groupRowsBy

I've been passing a function with this signature: (field: any) => string and my linter is flagging it as incompatible because string cannot be assigned to object. But the table seems to be working properly.

Is this a typing problem or a lack of documentation problem?

(for some reason this has only started making my pipelines fail after upgrading several packages, but what I see from the code suggest this error should have been occurring from the start)

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://stackblitz.com/edit/primevue-4-vite-issue-template-zrbz2qu5?file=src%2FApp.vue

Environment

Windows 11

Vue version

3.5.25

PrimeVue version

4.5.2

Node version

24.11.1

Browser(s)

No response

Steps to reproduce the behavior

  1. Have a DataTable
  2. Pass a function that returns a string to the groupRowsBy property.
  3. Use eslint

Expected behavior

No linter error.


Edit: I have seen this other issue: #8318
I seem to be using version 3.1.5 of vue-tsc, so I'm not sure this is exactly the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions