From 7cc32b194b034da189b6575aabfef2f5e48ff80b Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Sat, 27 Apr 2024 00:12:11 +0200 Subject: [PATCH] [DataGridPro] Use readonly array result for getTreeDataPath. We do not try to modify the array after receiving it, so let's accept an immutable array. This is still compatible with existing usage of getTreeDataPath. --- packages/x-data-grid-pro/src/models/dataGridProProps.ts | 2 +- .../x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/x-data-grid-pro/src/models/dataGridProProps.ts b/packages/x-data-grid-pro/src/models/dataGridProProps.ts index 4d611b57ea069..1af6cbe61f588 100644 --- a/packages/x-data-grid-pro/src/models/dataGridProProps.ts +++ b/packages/x-data-grid-pro/src/models/dataGridProProps.ts @@ -153,7 +153,7 @@ interface DataGridProRegularProps { * @param {R} row The row from which we want the path. * @returns {string[]} The path to the row. */ - getTreeDataPath?: (row: R) => string[]; + getTreeDataPath?: (row: R) => readonly string[]; } export interface DataGridProPropsWithoutDefaultValue diff --git a/packages/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx b/packages/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx index 9f80a0d0858e7..fa54187dbc27b 100644 --- a/packages/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx +++ b/packages/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx @@ -214,7 +214,7 @@ describe(' - Tree data', () => { ]); setProps({ getTreeDataPath: (row) => [...row.name.split('.').reverse()], - } as DataGridProProps); + } as Pick); expect(getColumnValues(1)).to.deep.equal([ 'A', 'A.A',