Skip to content

Commit

Permalink
disable feature inference for better ts performance for now
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Dec 18, 2024
1 parent bc69a07 commit 3c16d7a
Show file tree
Hide file tree
Showing 30 changed files with 288 additions and 252 deletions.
2 changes: 1 addition & 1 deletion packages/table-core/src/core/headers/buildHeaderGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function buildHeaderGroups<
depth,
id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
headers: [],
}
} as any

// The parent columns we're going to scan next
const pendingParentHeaders: Array<Header<TFeatures, TData, TValue>> = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export interface RowModel<
rowsById: Record<string, Row<TFeatures, TData>>
}

export interface CreateRowModel_Plugins {}

export interface CreateRowModel_Core<
TFeatures extends TableFeatures,
TData extends RowData,
> {
> extends CreateRowModel_Plugins {
/**
* This required option is a factory for a function that computes and returns the core row model for the table.
* [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)
Expand All @@ -32,10 +34,12 @@ export interface CreateRowModel_Core<
) => () => RowModel<TFeatures, TData>
}

export interface CachedRowModel_Plugins {}

export interface CachedRowModel_Core<
TFeatures extends TableFeatures,
TData extends RowData,
> {
> extends CachedRowModel_Plugins {
coreRowModel: () => RowModel<TFeatures, TData>
}

Expand Down
4 changes: 2 additions & 2 deletions packages/table-core/src/core/table/constructTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function constructTable<
const table = {} as unknown as Table<TFeatures, TData>

const defaultOptions = featuresList.reduce((obj, feature) => {
return Object.assign(obj, feature.getDefaultTableOptions?.(table))
return Object.assign(obj, feature.getDefaultTableOptions?.(table as any))
}, {}) as TableOptions<TFeatures, TData>

const initialState = getInitialTableState(_features, options.initialState)
Expand All @@ -57,7 +57,7 @@ export function constructTable<
Object.assign(table, coreInstance)

for (const feature of featuresList) {
feature.constructTableAPIs?.(table)
feature.constructTableAPIs?.(table as any)
}

return table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import {
column_getFacetedRowModel,
column_getFacetedUniqueValues,
} from './columnFacetingFeature.utils'
import type { Column_ColumnFaceting } from './columnFacetingFeature.types'
import type { RowData } from '../../types/type-utils'
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
import type { TableFeature } from '../../types/TableFeatures'
// import type { CachedRowModel_Faceted, Column_ColumnFaceting, CreateRowModel_Faceted } from './columnFacetingFeature.types'

/**
* The Column Faceting feature adds column faceting APIs to the column objects.
*/
export const columnFacetingFeature: TableFeature<{
Column: Column_ColumnFaceting<TableFeatures, RowData>
// Column: Column_ColumnFaceting<TableFeatures, RowData>
// CreateRowModels: CreateRowModel_Faceted<TableFeatures, RowData>
// CachedRowModel: CachedRowModel_Faceted<TableFeatures, RowData>
}> = {
constructColumnAPIs: (column) => {
assignAPIs(column, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import {
table_resetColumnFilters,
table_setColumnFilters,
} from './columnFilteringFeature.utils'
import type { RowData } from '../../types/type-utils'
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
import type {
ColumnDef_ColumnFiltering,
Column_ColumnFiltering,
Row_ColumnFiltering,
TableOptions_ColumnFiltering,
TableState_ColumnFiltering,
Table_ColumnFiltering,
} from './columnFilteringFeature.types'
import type { TableFeature } from '../../types/TableFeatures'
// import type {
// CachedRowModel_Filtered,
// ColumnDef_ColumnFiltering,
// Column_ColumnFiltering,
// CreateRowModel_Filtered,
// RowModelFns_ColumnFiltering,
// Row_ColumnFiltering,
// TableOptions_ColumnFiltering,
// TableState_ColumnFiltering,
// Table_ColumnFiltering,
// } from './columnFilteringFeature.types'

/**
* The Column Filtering feature adds column filtering state and APIs to the table, row, and column objects.
Expand All @@ -30,12 +32,15 @@ import type {
* [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
*/
export const columnFilteringFeature: TableFeature<{
Column: Column_ColumnFiltering<TableFeatures, RowData>
ColumnDef: ColumnDef_ColumnFiltering<TableFeatures, RowData>
Row: Row_ColumnFiltering<TableFeatures, RowData>
Table: Table_ColumnFiltering
TableOptions: TableOptions_ColumnFiltering<TableFeatures, RowData>
TableState: TableState_ColumnFiltering
// CachedRowModel: CachedRowModel_Filtered<TableFeatures, RowData>
// Column: Column_ColumnFiltering<TableFeatures, RowData>
// ColumnDef: ColumnDef_ColumnFiltering<TableFeatures, RowData>
// CreateRowModels: CreateRowModel_Filtered<TableFeatures, RowData>
// Row: Row_ColumnFiltering<TableFeatures, RowData>
// RowModelFns: RowModelFns_ColumnFiltering<TableFeatures, RowData>
// Table: Table_ColumnFiltering
// TableOptions: TableOptions_ColumnFiltering<TableFeatures, RowData>
// TableState: TableState_ColumnFiltering
}> = {
getInitialState: (initialState) => {
return {
Expand Down Expand Up @@ -85,8 +90,8 @@ export const columnFilteringFeature: TableFeature<{
},

constructRowAPIs: (row) => {
row.columnFilters = {}
row.columnFiltersMeta = {}
;(row as any).columnFilters = {}
;(row as any).columnFiltersMeta = {}
},

constructTableAPIs: (table) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface ResolvedColumnFilter<
resolvedValue: unknown
}

export interface TableFns_ColumnFiltering<
export interface RowModelFns_ColumnFiltering<
TFeatures extends TableFeatures,
TData extends RowData,
> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { functionalUpdate, isDev, isFunction } from '../../utils'
import { filterFn_weakEquals } from '../../fns/filterFns'
import type { CellData, RowData, Updater } from '../../types/type-utils'
import type { TableFeatures } from '../../types/TableFeatures'
import type { Table_Internal } from '../../types/Table'
Expand Down Expand Up @@ -58,7 +57,7 @@ export function column_getFilterFn<
column: Column<TFeatures, TData, TValue> & {
columnDef: ColumnDef_ColumnFiltering<TFeatures, TData>
},
): FilterFn<TFeatures, TData> {
): FilterFn<TFeatures, TData> | undefined {
let filterFn = null
const filterFns = column.table._rowModelFns.filterFns as
| Record<string, FilterFn<TFeatures, TData>>
Expand All @@ -69,13 +68,10 @@ export function column_getFilterFn<
? column_getAutoFilterFn(column)
: filterFns?.[column.columnDef.filterFn as string]

if (!filterFn) {
if (isDev) {
console.warn(
`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}. Using default filterFn: 'weakEquals'`,
)
}
filterFn = filterFn_weakEquals
if (isDev && !filterFn) {
console.warn(
`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,
)
}

return filterFn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function _createFilteredRowModel<
return
}

const filterFn = column_getFilterFn(column)
const filterFn = column_getFilterFn(column)!

resolvedColumnFilters.push({
id: columnFilter.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,36 @@ import {
table_resetGrouping,
table_setGrouping,
} from './columnGroupingFeature.utils'
import type { CellData, RowData } from '../../types/type-utils'
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
import type {
Cell_ColumnGrouping,
ColumnDef_ColumnGrouping,
Column_ColumnGrouping,
Row_ColumnGrouping,
TableOptions_ColumnGrouping,
TableState_ColumnGrouping,
Table_ColumnGrouping,
} from './columnGroupingFeature.types'
import type { TableFeature } from '../../types/TableFeatures'
// import type {
// CachedRowModel_Grouped,
// Cell_ColumnGrouping,
// ColumnDef_ColumnGrouping,
// Column_ColumnGrouping,
// CreateRowModel_Grouped,
// RowModelFns_ColumnGrouping,
// Row_ColumnGrouping,
// TableOptions_ColumnGrouping,
// TableState_ColumnGrouping,
// Table_ColumnGrouping,
// } from './columnGroupingFeature.types'

/**
* The (Column) Grouping feature adds column grouping state and APIs to the table, row, column, and cell objects.
* [API Docs](https://tanstack.com/table/v8/docs/api/features/column-grouping)
* [Guide](https://tanstack.com/table/v8/docs/guide/column-grouping)
*/
export const columnGroupingFeature: TableFeature<{
Cell: Cell_ColumnGrouping
Column: Column_ColumnGrouping<TableFeatures, RowData>
ColumnDef: ColumnDef_ColumnGrouping<TableFeatures, RowData, CellData>
Row: Row_ColumnGrouping
Table: Table_ColumnGrouping<TableFeatures, RowData>
TableOptions: TableOptions_ColumnGrouping
TableState: TableState_ColumnGrouping
// CachedRowModel: CachedRowModel_Grouped<TableFeatures, RowData>
// Cell: Cell_ColumnGrouping
// Column: Column_ColumnGrouping<TableFeatures, RowData>
// ColumnDef: ColumnDef_ColumnGrouping<TableFeatures, RowData, CellData>
// CreateRowModels: CreateRowModel_Grouped<TableFeatures, RowData>
// Row: Row_ColumnGrouping
// RowModelFns: RowModelFns_ColumnGrouping<TableFeatures, RowData>
// Table: Table_ColumnGrouping<TableFeatures, RowData>
// TableOptions: TableOptions_ColumnGrouping
// TableState: TableState_ColumnGrouping
}> = {
getInitialState: (initialState) => {
return {
Expand Down Expand Up @@ -104,7 +109,7 @@ export const columnGroupingFeature: TableFeature<{
},

constructRowAPIs: (row) => {
row._groupingValuesCache = {}
;(row as any)._groupingValuesCache = {}

assignAPIs(row, [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface TableState_ColumnGrouping {
grouping: GroupingState
}

export interface TableFns_ColumnGrouping<
export interface RowModelFns_ColumnGrouping<
TFeatures extends TableFeatures,
TData extends RowData,
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import {
table_resetColumnOrder,
table_setColumnOrder,
} from './columnOrderingFeature.utils'
import type { RowData } from '../../types/type-utils'
import type {
Column_ColumnOrdering,
TableOptions_ColumnOrdering,
TableState_ColumnOrdering,
Table_ColumnOrdering,
} from './columnOrderingFeature.types'
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
// import type {
// Column_ColumnOrdering,
// TableOptions_ColumnOrdering,
// TableState_ColumnOrdering,
// Table_ColumnOrdering,
// } from './columnOrderingFeature.types'
import type { TableFeature } from '../../types/TableFeatures'

/**
* The Column Ordering feature adds column ordering state and APIs to the table and column objects.
* [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering)
* [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)
*/
export const columnOrderingFeature: TableFeature<{
Column: Column_ColumnOrdering
Table: Table_ColumnOrdering<TableFeatures, RowData>
TableOptions: TableOptions_ColumnOrdering
TableState: TableState_ColumnOrdering
// Column: Column_ColumnOrdering
// Table: Table_ColumnOrdering<TableFeatures, RowData>
// TableOptions: TableOptions_ColumnOrdering
// TableState: TableState_ColumnOrdering
}> = {
getInitialState: (initialState) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,28 @@ import {
table_resetColumnPinning,
table_setColumnPinning,
} from './columnPinningFeature.utils'
import type { RowData } from '../../types/type-utils'
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
import type {
ColumnDef_ColumnPinning,
Column_ColumnPinning,
Row_ColumnPinning,
TableOptions_ColumnPinning,
TableState_ColumnPinning,
Table_ColumnPinning,
} from './columnPinningFeature.types'
import type { TableFeature } from '../../types/TableFeatures'
// import type {
// ColumnDef_ColumnPinning,
// Column_ColumnPinning,
// Row_ColumnPinning,
// TableOptions_ColumnPinning,
// TableState_ColumnPinning,
// Table_ColumnPinning,
// } from './columnPinningFeature.types'

/**
* The Column Pinning feature adds column pinning state and APIs to the table, row, and column objects.
* [API Docs](https://tanstack.com/table/v8/docs/api/features/column-pinning)
* [Guide](https://tanstack.com/table/v8/docs/guide/column-pinning)
*/
export const columnPinningFeature: TableFeature<{
Column: Column_ColumnPinning
ColumnDef: ColumnDef_ColumnPinning
Row: Row_ColumnPinning<TableFeatures, RowData>
Table: Table_ColumnPinning<TableFeatures, RowData>
TableOptions: TableOptions_ColumnPinning
TableState: TableState_ColumnPinning
// Column: Column_ColumnPinning
// ColumnDef: ColumnDef_ColumnPinning
// Row: Row_ColumnPinning<TableFeatures, RowData>
// Table: Table_ColumnPinning<TableFeatures, RowData>
// TableOptions: TableOptions_ColumnPinning
// TableState: TableState_ColumnPinning
}> = {
getInitialState: (initialState) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
table_setColumnResizing,
} from './columnResizingFeature.utils'
import type { TableFeature } from '../../types/TableFeatures'
import type {
Column_ColumnResizing,
Header_ColumnResizing,
TableOptions_ColumnResizing,
TableState_ColumnResizing,
Table_ColumnResizing,
} from './columnResizingFeature.types'
// import type {
// Column_ColumnResizing,
// Header_ColumnResizing,
// TableOptions_ColumnResizing,
// TableState_ColumnResizing,
// Table_ColumnResizing,
// } from './columnResizingFeature.types'

/**
* The Column Resizing feature adds column resizing state and APIs to the table and column objects.
Expand All @@ -24,11 +24,11 @@ import type {
* [Guide](https://tanstack.com/table/v8/docs/guide/column-resizing)
*/
export const columnResizingFeature: TableFeature<{
Column: Column_ColumnResizing
Header: Header_ColumnResizing
Table: Table_ColumnResizing
TableOptions: TableOptions_ColumnResizing
TableState: TableState_ColumnResizing
// Column: Column_ColumnResizing
// Header: Header_ColumnResizing
// Table: Table_ColumnResizing
// TableOptions: TableOptions_ColumnResizing
// TableState: TableState_ColumnResizing
}> = {
getInitialState: (initialState) => {
return {
Expand Down
Loading

0 comments on commit 3c16d7a

Please sign in to comment.