diff --git a/packages/angular-table/src/helpers/createTableHook.ts b/packages/angular-table/src/helpers/createTableHook.ts index 09c7920094..e6c8215157 100644 --- a/packages/angular-table/src/helpers/createTableHook.ts +++ b/packages/angular-table/src/helpers/createTableHook.ts @@ -154,7 +154,7 @@ type AppGroupColumnDef< footer?: AppColumnDefTemplate< AppHeaderContext > - columns?: Array> + columns?: ReadonlyArray> } // ============================================================================= diff --git a/packages/table-core/src/core/columns/coreColumnsFeature.types.ts b/packages/table-core/src/core/columns/coreColumnsFeature.types.ts index 920d81fc4b..b617b8a08b 100644 --- a/packages/table-core/src/core/columns/coreColumnsFeature.types.ts +++ b/packages/table-core/src/core/columns/coreColumnsFeature.types.ts @@ -65,7 +65,7 @@ export interface TableOptions_Columns< /** * The array of column defs to use for the table. */ - columns: Array> + columns: ReadonlyArray> /** * Default column options to use for all column defs supplied to the table. */ diff --git a/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts b/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts index 6afaaa4044..b134ec2866 100644 --- a/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts +++ b/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts @@ -79,7 +79,7 @@ export function table_getAllColumns< table: Table_Internal, ): Array> { const recurseColumns = ( - colDefs: Array>, + colDefs: ReadonlyArray>, parent?: Column, depth = 0, ): Array> => { diff --git a/packages/table-core/src/core/row-models/createCoreRowModel.ts b/packages/table-core/src/core/row-models/createCoreRowModel.ts index 8d3bd55781..bdad564663 100644 --- a/packages/table-core/src/core/row-models/createCoreRowModel.ts +++ b/packages/table-core/src/core/row-models/createCoreRowModel.ts @@ -29,7 +29,7 @@ function _createCoreRowModel< TData extends RowData, >( table: Table_Internal, - data: Array, + data: ReadonlyArray, ): { rows: Array> flatRows: Array> @@ -42,7 +42,7 @@ function _createCoreRowModel< } const accessRows = ( - originalRows: Array, + originalRows: ReadonlyArray, depth = 0, parentRow?: Row, ): Array> => { diff --git a/packages/table-core/src/core/rows/coreRowsFeature.types.ts b/packages/table-core/src/core/rows/coreRowsFeature.types.ts index 617f78292f..674f08c7b0 100644 --- a/packages/table-core/src/core/rows/coreRowsFeature.types.ts +++ b/packages/table-core/src/core/rows/coreRowsFeature.types.ts @@ -29,7 +29,7 @@ export interface Row_CoreProperties< /** * An array of the original subRows as returned by the `options.getSubRows` option. */ - originalSubRows?: Array + originalSubRows?: ReadonlyArray /** * If nested, this row's parent row id. */ @@ -96,7 +96,10 @@ export interface TableOptions_Rows< * This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row. * @example getSubRows: row => row.subRows */ - getSubRows?: (originalRow: TData, index: number) => undefined | Array + getSubRows?: ( + originalRow: TData, + index: number, + ) => undefined | ReadonlyArray } export interface Table_Rows< diff --git a/packages/table-core/src/core/table/coreTablesFeature.types.ts b/packages/table-core/src/core/table/coreTablesFeature.types.ts index 53e88695f9..0124eac018 100644 --- a/packages/table-core/src/core/table/coreTablesFeature.types.ts +++ b/packages/table-core/src/core/table/coreTablesFeature.types.ts @@ -31,7 +31,7 @@ export interface TableOptions_Table< /** * The data for the table to display. When the `data` option changes reference, the table will reprocess the data. */ - data: Array + data: ReadonlyArray /** * Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state. * Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable. diff --git a/packages/table-core/src/types/ColumnDef.ts b/packages/table-core/src/types/ColumnDef.ts index 0a2ba4b16e..de0456d6a4 100644 --- a/packages/table-core/src/types/ColumnDef.ts +++ b/packages/table-core/src/types/ColumnDef.ts @@ -150,7 +150,7 @@ type GroupColumnDefBase< TData extends RowData, TValue extends CellData = CellData, > = ColumnDefBase & { - columns?: Array> + columns?: ReadonlyArray> } export type GroupColumnDef< diff --git a/packages/table-devtools/src/components/RowsPanel.tsx b/packages/table-devtools/src/components/RowsPanel.tsx index f840c6ed0b..3320436032 100644 --- a/packages/table-devtools/src/components/RowsPanel.tsx +++ b/packages/table-devtools/src/components/RowsPanel.tsx @@ -62,7 +62,7 @@ export function RowsPanel() { 'No table instance is connected. Pass a table instance to TableDevtoolsPanel.', } } - const data = tableInstance.options.data as Array + const data = tableInstance.options.data as ReadonlyArray if (!Array.isArray(data)) return data if (data.length <= ROW_LIMIT) return data as unknown return data.slice(0, ROW_LIMIT) as unknown @@ -71,7 +71,7 @@ export function RowsPanel() { const getRawDataTotalCount = (): number => { tableState?.() if (!tableInstance) return 0 - const data = tableInstance.options.data as Array + const data = tableInstance.options.data as ReadonlyArray return Array.isArray(data) ? data.length : 0 } diff --git a/packages/vue-table/src/useTable.ts b/packages/vue-table/src/useTable.ts index b4d851c878..27d6dc7fc2 100644 --- a/packages/vue-table/src/useTable.ts +++ b/packages/vue-table/src/useTable.ts @@ -16,7 +16,7 @@ export type TableOptionsWithReactiveData< TFeatures extends TableFeatures, TData extends RowData, > = Omit, 'data'> & { - data: MaybeRef> + data: MaybeRef> } function getOptionsWithReactiveData<