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

DataTable: DataTableSortMeta field missing type definition #5862

Closed
MalikBen opened this issue Jun 10, 2024 · 0 comments · Fixed by #5863
Closed

DataTable: DataTableSortMeta field missing type definition #5862

MalikBen opened this issue Jun 10, 2024 · 0 comments · Fixed by #5863
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@MalikBen
Copy link
Contributor

MalikBen commented Jun 10, 2024

Describe the bug

When using DataTable with sort="multiple" and pre filtering a column with multi-sort-meta, the multi-sort-meta prop is of type DataTableSortMeta, which is defined like this :

export interface DataTableSortMeta {
    /**
     * Column field
     */
    field: string;
    /**
     * Column sort order
     */
    order: 1 | 0 | -1 | undefined | null;
}

But if we use a custom sorting function in the column with the sort-field prop and want it to be used in the initial sorting, we can pass it to field in the multi-sort-meta prop of DataTable.

If you look at the example, a function is passed and it works correctly.
But if you remove the @ts-nocheck at line 2, typescript will throw an error.

I think the DataTableSortMeta field prop should have this type instead:

field: string | (item: any) => string;

Reproducer

https://stackblitz.com/edit/vitejs-vite-7s9x9r?file=src%2FApp.vue

PrimeVue version

3.52.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to App.vue
  2. Remove @ts-nocheck at line 2
  3. Typescript throws an error

Expected behavior

Typescript should not throw an error

@MalikBen MalikBen added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 10, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jun 10, 2024
@tugcekucukoglu tugcekucukoglu added this to the 3.53.0 milestone Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants