Skip to content

Commit

Permalink
fix: DataView setFilter had incorrect type, fixes #848 (#849)
Browse files Browse the repository at this point in the history
- `setFilter` had the incorrect type, it should be `filterFn: (item: T, args: any) => boolean` and that is inline with what `filter` callback is defined on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#parameters
  • Loading branch information
ghiscoding authored Sep 27, 2023
1 parent 72e13e2 commit 3efb3f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/slick.dataview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface DataViewOption {
groupItemMetadataProvider: SlickGroupItemMetadataProvider_ | null;
inlineFilters: boolean;
}
export type FilterFn<T> = (a: T, b: T) => boolean;
export type FilterFn<T> = (item: T, args: any) => boolean;
export type DataIdType = number | string;
export type SlickDataItem = SlickNonDataItem | SlickGroup_ | SlickGroupTotals_ | any;

Expand Down Expand Up @@ -366,7 +366,7 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
* Set a Filter that will be used by the DataView
* @param {Function} fn - filter callback function
*/
setFilter(filterFn: (a: TData, b: TData) => boolean) {
setFilter(filterFn: FilterFn<TData>) {
this.filter = filterFn;
if (this._options.inlineFilters) {
this.compiledFilter = this.compileFilter();
Expand Down

0 comments on commit 3efb3f5

Please sign in to comment.