Skip to content

Commit 3efb3f5

Browse files
authored
fix: DataView setFilter had incorrect type, fixes #848 (#849)
- `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
1 parent 72e13e2 commit 3efb3f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/slick.dataview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface DataViewOption {
3737
groupItemMetadataProvider: SlickGroupItemMetadataProvider_ | null;
3838
inlineFilters: boolean;
3939
}
40-
export type FilterFn<T> = (a: T, b: T) => boolean;
40+
export type FilterFn<T> = (item: T, args: any) => boolean;
4141
export type DataIdType = number | string;
4242
export type SlickDataItem = SlickNonDataItem | SlickGroup_ | SlickGroupTotals_ | any;
4343

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

0 commit comments

Comments
 (0)