Skip to content

Grids: type m_header_filter - #35897

Open
Alyar666 wants to merge 3 commits into
DevExpress:mainfrom
Alyar666:typescript/grids/header_filter_typing_5282
Open

Alyar666 wants to merge 3 commits into
DevExpress:mainfrom
Alyar666:typescript/grids/header_filter_typing_5282

Conversation

@Alyar666

Copy link
Copy Markdown
Contributor

No description provided.

@Alyar666
Alyar666 requested a review from a team as a code owner October 22, 2026 22:56
@Alyar666 Alyar666 self-assigned this Oct 22, 2026
@Alyar666
Alyar666 force-pushed the typescript/grids/header_filter_typing_5282 branch from dbb02a5 to 8b98d23 Compare October 22, 2026 23:11
Comment on lines 368 to 370
// eslint-disable-next-line @stylistic/max-len
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- fail ignores the result
}).fail(d.reject);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we cast d.reject like in data_controller.ts and drop both disables?

Suggested change
// eslint-disable-next-line @stylistic/max-len
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- fail ignores the result
}).fail(d.reject);
}).fail(d.reject as (...args: unknown[]) => void);

Comment on lines +278 to +281
const displaySelector: HeaderFilterGroupSelector | undefined = lookup
// @ts-expect-error compileGetter() is overloaded and cannot pick one for a union argument
? compileGetter<HeaderFilterGroupSelector>(lookup.displayExpr)
: undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileGetter returns a function argument as is, so maybe narrowing with isFunction lets us remove the directive?

Suggested change
const displaySelector: HeaderFilterGroupSelector | undefined = lookup
// @ts-expect-error compileGetter() is overloaded and cannot pick one for a union argument
? compileGetter<HeaderFilterGroupSelector>(lookup.displayExpr)
: undefined;
const displayExpr = lookup?.displayExpr;
const displaySelector: HeaderFilterGroupSelector | undefined = isFunction(displayExpr)
? displayExpr
: lookup && compileGetter(displayExpr);

Comment on lines 533 to 534
// @ts-expect-error updateColumnIndexes sets the index of every column
this._headerFilterController.showHeaderFilterMenu(column.index, false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about a guard like in m_sorting.ts instead of the directive?

Suggested change
// @ts-expect-error updateColumnIndexes sets the index of every column
this._headerFilterController.showHeaderFilterMenu(column.index, false);
if (isDefined(column.index)) {
this._headerFilterController.showHeaderFilterMenu(column.index, false);
}

Comment on lines +611 to +612
// @ts-expect-error updateColumnIndexes sets the index of every column
this._headerFilterController.showHeaderFilterMenu(groupColumn.index, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, and probably for columnIndex in m_grouping.ts too

Suggested change
// @ts-expect-error updateColumnIndexes sets the index of every column
this._headerFilterController.showHeaderFilterMenu(groupColumn.index, true);
if (isDefined(groupColumn.index)) {
this._headerFilterController.showHeaderFilterMenu(groupColumn.index, true);
}

Comment on lines +586 to +590
private _createGroupPanelItem(
$rootElement: dxElementWrapper,
groupColumn: Column,
): dxElementWrapper {
// @ts-expect-error DataGrid's method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorting already declares it protected with this reason text - should we align so one grep finds every DataGrid grouping leak?

Suggested change
private _createGroupPanelItem(
$rootElement: dxElementWrapper,
groupColumn: Column,
): dxElementWrapper {
// @ts-expect-error DataGrid's method
protected _createGroupPanelItem(
$rootElement: dxElementWrapper,
groupColumn: Column,
): dxElementWrapper {
// @ts-expect-error _createGroupPanelItem is defined by DataGrid grouping

Comment on lines +51 to +56
export interface NormalizeGroupItemOptions
extends Pick<ProcessGroupItemsOptions, 'column' | 'headerFilterOptions'> {
path: unknown[];
valueSelector?: HeaderFilterGroupSelector;
displaySelector?: HeaderFilterGroupSelector;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about declaring the fields directly instead of Pick?

Suggested change
export interface NormalizeGroupItemOptions
extends Pick<ProcessGroupItemsOptions, 'column' | 'headerFilterOptions'> {
path: unknown[];
valueSelector?: HeaderFilterGroupSelector;
displaySelector?: HeaderFilterGroupSelector;
}
export interface NormalizeGroupItemOptions {
column: Column;
headerFilterOptions?: HeaderFilter;
path: unknown[];
valueSelector?: HeaderFilterGroupSelector;
displaySelector?: HeaderFilterGroupSelector;
}

}

public getDataSource(column) {
public getDataSource(column: HeaderFilterColumn): HeaderFilterDataSourceOptions | undefined {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returning | undefined here adds directives in filter_custom_operations.ts and in showHeaderFilterMenuBase - would a guard at those callers work, or should the return stay broad for now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would change the behavior: adding a guard at the call sites would turn today's TypeError into a silent no-op.

});
const column: Column = extend(true, {}, this._columnsController.getColumns()[columnIndex]);

if (!column) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extend(true, {}, ...) always returns an object, so this check never fires - could hasCellValueCalculator(column) replace it and also remove the calculateCellValue directive below?

);

if (!text) {
// @ts-expect-error the default options provide texts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use ?. here instead of the directive, like in core?

}

items = origPostProcess && origPostProcess.call(this, items) || items;
items = origPostProcess?.call(this, items) ?? items;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? items differs from the old || when postProcess returns a falsy non-array value - intended?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants