Skip to content

fix: improve ts perf with feature maps#6299

Merged
KevinVandy merged 1 commit into
betafrom
improve-ts-perf
Jun 7, 2026
Merged

fix: improve ts perf with feature maps#6299
KevinVandy merged 1 commit into
betafrom
improve-ts-perf

Conversation

@KevinVandy
Copy link
Copy Markdown
Member

@KevinVandy KevinVandy commented Jun 7, 2026

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

Summary by CodeRabbit

  • Refactor
    • Unified type composition approach across type definitions using feature map interfaces and ExtractFeatureMapTypes utility.
    • Replaced conditional union-to-intersection logic with explicit feature mapping patterns for improved maintainability.
    • Updated internal type organization across multiple table feature types without changes to the public API.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c3826f0-8c00-4123-ab93-62f91f7a62bc

📥 Commits

Reviewing files that changed from the base of the PR and between f906d2d and 8a90868.

📒 Files selected for processing (13)
  • packages/angular-table/src/injectTable.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/types/Cell.ts
  • packages/table-core/src/types/Column.ts
  • packages/table-core/src/types/ColumnDef.ts
  • packages/table-core/src/types/Header.ts
  • packages/table-core/src/types/Row.ts
  • packages/table-core/src/types/RowModel.ts
  • packages/table-core/src/types/RowModelFns.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
  • packages/table-core/src/types/TableOptions.ts
  • packages/table-core/src/types/TableState.ts

📝 Walkthrough

Walkthrough

This PR systematically refactors the table library's type composition system by replacing inline UnionToIntersection conditionals with explicit feature-map interfaces and a new ExtractFeatureMapTypes utility, applied across all core type definitions and accompanied by snapshot assignment type-casting adjustments.

Changes

Type System and Snapshot Composition

Layer / File(s) Summary
Feature map extraction utility
packages/table-core/src/types/TableFeatures.ts
Added ExtractFeatureMapTypes<TFeatures, TFeatureMap> type that computes a union-to-intersection from feature-to-type maps, with conditional logic for any-typed feature sets.
Cell and Header feature maps
packages/table-core/src/types/Cell.ts, packages/table-core/src/types/Header.ts
Introduced Cell_FeatureMap and Header_FeatureMap to map feature keys to their cell and header types; refactored Cell and Header type composition to use ExtractFeatureMapTypes instead of inline conditionals.
Column and ColumnDef feature maps
packages/table-core/src/types/Column.ts, packages/table-core/src/types/ColumnDef.ts
Introduced Column_FeatureMap and ColumnDef_FeatureMap to centralize feature property composition; updated Column and ColumnDefBase to derive feature intersections via ExtractFeatureMapTypes.
Row feature map
packages/table-core/src/types/Row.ts
Introduced Row_FeatureMap mapping row-level features (columnFilteringFeature, columnPinningFeature, rowSelectionFeature, etc.); refactored Row type to use ExtractFeatureMapTypes and removed commented-out type definition.
Row models and functions feature maps
packages/table-core/src/types/RowModel.ts, packages/table-core/src/types/RowModelFns.ts
Introduced CreateRowModels_FeatureMap, CachedRowModels_FeatureMap, and RowModelFns_FeatureMap; refactored all three types to compose via ExtractFeatureMapTypes instead of conditional unions.
Table, TableOptions, and TableState feature maps
packages/table-core/src/types/Table.ts, packages/table-core/src/types/TableOptions.ts, packages/table-core/src/types/TableState.ts
Introduced Table_FeatureMap, TableOptions_FeatureMap, and TableState_FeatureMap; refactored Table, TableOptions, TableState (and TableOptions_All) to derive feature-specific APIs/options/state via ExtractFeatureMapTypes instead of inline conditional unions.
Snapshot assignment type casts
packages/angular-table/src/injectTable.ts, packages/table-core/src/core/table/constructTable.ts
Updated snapshot building to assign via Record<string, unknown> cast instead of direct typed indexing, adjusting TypeScript typing compatibility while preserving the value source (table.atoms[key].get()).

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TanStack/table#6268: Refactors snapshot construction in constructTable.ts and adjusts snapshot-building loops—complementary to this PR's snapshot type-casting update.

Suggested reviewers

  • schiller-manuel

🐰 With feature maps in place, the types now compose with grace,
No more conditionals scattered all over the place!
ExtractFeatureMapTypes brings order and light,
Where UnionToIntersection once tangled the sight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: refactoring TypeScript feature composition to use explicit feature maps instead of UnionToIntersection for performance improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve-ts-perf

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 7, 2026

View your CI Pipeline Execution ↗ for commit 8a90868

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 2m 52s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 27s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-07 14:08:06 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 7, 2026

More templates

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6299

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6299

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6299

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6299

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6299

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6299

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6299

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6299

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6299

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6299

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6299

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6299

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6299

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6299

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6299

commit: 8a90868

@KevinVandy KevinVandy merged commit 97f0b07 into beta Jun 7, 2026
8 checks passed
@KevinVandy KevinVandy deleted the improve-ts-perf branch June 7, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant