Skip to content

Commit

Permalink
chore: add more TS types to DataView
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Dec 7, 2023
1 parent cd29a24 commit 36173fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/models/dataViewHints.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface DataViewHints {
ignoreDiffsBefore?: number;
ignoreDiffsAfter?: number;
isFilterNarrowing?: boolean;
isFilterExpanding?: boolean;
isFilterUnchanged?: boolean;
}
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './core.interface';
export * from './cssDeclaration.interface';
export * from './customTooltipOption.interface';
export * from './dataViewEvents.interface';
export * from './dataViewHints.interface';
export * from './domEvent.interface';
export * from './drag.interface';
export * from './draggableGroupingOption.interface';
Expand Down
26 changes: 12 additions & 14 deletions src/slick.dataview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
Aggregator,
CssStyleHash,
CustomDataView,
DataViewHints,
Grouping,
GroupingFormatterItem,
ItemMetadata,
Expand Down Expand Up @@ -77,8 +78,8 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
protected sortAsc: boolean | undefined = true;
protected fastSortField?: string | null | (() => string);
protected sortComparer!: ((a: TData, b: TData) => number);
protected refreshHints: any = {};
protected prevRefreshHints: any = {};
protected refreshHints: DataViewHints = {};
protected prevRefreshHints: DataViewHints = {};
protected filterArgs: any;
protected filteredItems: TData[] = [];
protected compiledFilter?: FilterFn<TData> | null;
Expand Down Expand Up @@ -187,7 +188,7 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
}
}

setRefreshHints(hints: any) {
setRefreshHints(hints: DataViewHints) {
this.refreshHints = hints;
}

Expand Down Expand Up @@ -832,8 +833,8 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
collapseGroup(...args: any) {
const calledArgs = Array.prototype.slice.call(args);
const arg0 = calledArgs[0];
let groupingKey;
let level;
let groupingKey: string;
let level: number;

if (args.length === 1 && arg0.indexOf(this.groupingDelimiter) !== -1) {
groupingKey = arg0;
Expand All @@ -856,8 +857,8 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
expandGroup(...args: any) {
const calledArgs = Array.prototype.slice.call(args);
const arg0 = calledArgs[0];
let groupingKey;
let level;
let groupingKey: string;
let level: number;

if (args.length === 1 && arg0.indexOf(this.groupingDelimiter) !== -1) {
level = arg0.split(this.groupingDelimiter).length - 1;
Expand All @@ -876,8 +877,8 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
}

protected extractGroups(rows: any[], parentGroup?: SlickGroup_) {
let group;
let val;
let group: SlickGroup_;
let val: any;
const groups: SlickGroup_[] = [];
const groupsByVal: any = {};
let r;
Expand Down Expand Up @@ -1182,10 +1183,7 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
*/
protected setFunctionName(fn: any, fnName: string) {
try {
Object.defineProperty(fn, 'name', {
writable: true,
value: fnName
});
Object.defineProperty(fn, 'name', { writable: true, value: fnName });
} catch (err) {
fn.name = fnName;
}
Expand Down Expand Up @@ -1265,7 +1263,7 @@ export class SlickDataView<TData extends SlickDataItem = any> implements CustomD
}

protected getRowDiffs(rows: TData[], newRows: TData[]) {
let item: any;
let item: TData | SlickNonDataItem | SlickDataItem | SlickGroup_;
let r;
let eitherIsNonData;
const diff: number[] = [];
Expand Down

0 comments on commit 36173fc

Please sign in to comment.