Skip to content

GridCore - Fix eslint and add types to leaf helpers (m_aggregate_calculator, m_utils, m_accessibility, m_export) - #35464

Merged
Alyar666 merged 12 commits into
DevExpress:mainfrom
Tucchhaa:fix_eslint_n_types_26_2
Oct 7, 2026
Merged

Alyar666 merged 12 commits into
DevExpress:mainfrom
Tucchhaa:fix_eslint_n_types_26_2

Conversation

@Tucchhaa

@Tucchhaa Tucchhaa commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@Tucchhaa
Tucchhaa requested a balanced review from Copilot October 5, 2026 02:13
@Tucchhaa Tucchhaa self-assigned this Oct 5, 2026
@Tucchhaa Tucchhaa added the 26_2 label Oct 5, 2026

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The aggregate calculator’s new row type incorrectly excludes supported primitive data rows.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds TypeScript typing and ESLint-compliant refactors to GridCore helper modules.

Changes:

  • Types aggregate calculation, export, accessibility, and filter helpers.
  • Replaces legacy loops/utilities with typed native constructs.
  • Updates aggregate test fixtures to object-based rows.
File Description
aggregateCalculator.tests.js Updates aggregate fixtures and selectors.
m_export.ts Types export item preparation.
m_accessibility.ts Types keyboard action registration.
summary/​types.ts Makes the custom aggregator group index optional.
summary/​m_summary.ts Types aggregate input data.
m_utils.ts Types group-filter construction.
m_aggregate_calculator.ts Types and modernizes aggregate calculations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Tucchhaa
Tucchhaa force-pushed the fix_eslint_n_types_26_2 branch from 488657c to 0f0c79b Compare October 5, 2026 03:00
@Tucchhaa
Tucchhaa marked this pull request as ready for review October 5, 2026 05:53
@Tucchhaa
Tucchhaa requested a review from a team as a code owner October 5, 2026 05:53
Copilot AI balanced review requested due to automatic review settings October 5, 2026 05:53

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The changes are consistent, mechanically preserve existing behavior, and are covered by established aggregate and export tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

bit-byte0
bit-byte0 previously approved these changes Oct 5, 2026

export default class AggregateCalculator {
private readonly _data: any;
private readonly _data: unknown[];

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 get better type from usage and docs?

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.

By checking usage of _data in source code its type should be: RawItemData[] | GroupData<RawItemData>[]

However, I have chosen to type unknown instead, because of this reasons:

  1. Data items are just passed to handler: aggregate.selector(item) to extract needed value and their props are never directly read. Only the .items prop is read if data item is actually a group item: line of code

  2. aggregateCalculator.tests.ts and dataSource.tests.ts have tests in which _data has number type. Defining type of _data would also require us to update these tests. (This is doable actually, not a lot of such tests)

I'm OK with both approaches. What do you think?

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.

we already typed data in calculateTotalAggregates that calls constructor of that class, the only issue is tests then, we can add ts-expect-error directive to tests, if there are too many of them, but if not better fix

private _aggregate(
aggregates: NormalizedAggregate[],
data: AggregateNode,
container: unknown[],

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 get better type from usage and docs?

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.

I think unknown is the accurate type here, because custom accumulator can return any value. We would need to define a broad type: number | string | object | etc for it, but it wouldn't be useful anyways, because grid already treats summary results as unknowns.

Comment on lines +196 to +197
results: unknown[],
item: unknown,

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 get better types from usage and docs?

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.

results is the same variable as container in this comment: #35464 (comment)
item depends on this resolution of this comment: #35464 (comment)

const groups = normalizeSortingInfo(storeLoadOptions.group);

const filter: any = [];
const filter: unknown[] = [];

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 some type from our existing filter types or get one from usage and docs?

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.

The existing filter types don't fit here. The group selector can be a function (e.g. calculateGroupValue), and a group key can be any value. DataFilter expects a string selector and a scalar value, so DataFilter[] fails with TS2345. The public FilterDescriptor is just any. combineFilters takes unknown[] anyway, so I'd keep unknown[] here.

Comment thread packages/devextreme/js/__internal/grids/grid_core/m_accessibility.ts Outdated
Comment thread packages/devextreme/js/__internal/grids/grid_core/m_export.ts
Copilot AI balanced review requested due to automatic review settings October 5, 2026 13:43

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The new View import references a nonexistent module and prevents TypeScript resolution.

Review effort: Balanced
Findings: 1 High severity

Open (1)

Comment thread packages/devextreme/js/__internal/grids/grid_core/m_accessibility.ts Outdated
Copilot AI balanced review requested due to automatic review settings October 5, 2026 13:59

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The new spread merge changes PivotGrid placeholder output and breaks an existing export assertion.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread packages/devextreme/js/__internal/grids/grid_core/m_export.ts
@Alyar666 Alyar666 self-assigned this Oct 6, 2026
@Alyar666
Alyar666 self-requested a review October 6, 2026 12:56
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:51
@Alyar666
Alyar666 removed their request for review October 6, 2026 14:51

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

Two new type contracts incorrectly permit unsafe export calls and exclude supported primitive summary rows.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Preserve primitive row support in RawItemData annotation

packages/​devextreme/​js/​__internal/​grids/​data_grid/​summary/​m_summary.ts:354

This annotation excludes supported primitive rows because RawItemData is Record<string, unknown>. The calculator explicitly supports stores of primitives (for example, numeric rows with the this selector), so this private boundary should preserve that input instead of narrowing it to objects.

Comment thread packages/devextreme/js/__internal/grids/grid_core/m_export.ts Outdated
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:21

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The changes are consistent type and lint refinements with no unresolved correctness issues found.

Review effort: Balanced
Findings: None

Resolved since last review (1)

anna-shakhova
anna-shakhova previously approved these changes Oct 7, 2026

export default class AggregateCalculator {
private readonly _data: any;
private readonly _data: unknown[];

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.

we already typed data in calculateTotalAggregates that calls constructor of that class, the only issue is tests then, we can add ts-expect-error directive to tests, if there are too many of them, but if not better fix

Copilot AI balanced review requested due to automatic review settings October 7, 2026 11:28
@Alyar666
Alyar666 requested a review from anna-shakhova October 7, 2026 11:32

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

Several new contracts exclude supported inputs or promise fields absent at runtime.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Allow primitive mapped items in aggregation

packages/​devextreme/​js/​__internal/​grids/​data_grid/​summary/​m_summary.ts:354

This annotation also excludes primitive items produced by DataSource.map, although aggregation supports them (dataSource.tests.js:357-384 exercises a mapped number). Keep this method's data type aligned with the calculator's supported generic/unknown row type rather than restricting it to RawItemData.

Medium severity NativeEventInfo does not match the callback payload

packages/​devextreme/​js/​__internal/​grids/​grid_core/​m_accessibility.ts:8

fireKeyDownEvent invokes this callback with only { event, handled } (ui/shared/accessibility.ts:71-78), so NativeEventInfo incorrectly promises component and element fields that are not present. Model the actual callback payload instead; otherwise future code can access fields that are always undefined.

Comment thread packages/devextreme/js/__internal/grids/grid_core/m_export.ts
@Alyar666
Alyar666 added this pull request to the merge queue Oct 7, 2026
Merged via the queue into DevExpress:main with commit fe1f34b Oct 7, 2026
196 of 197 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants