Skip to content

simplify type#7309

Open
schiller-manuel wants to merge 2 commits intomainfrom
simplify-type
Open

simplify type#7309
schiller-manuel wants to merge 2 commits intomainfrom
simplify-type

Conversation

@schiller-manuel
Copy link
Copy Markdown
Contributor

@schiller-manuel schiller-manuel commented May 1, 2026

Summary by CodeRabbit

  • Breaking Changes
    • Removed an exported type used by downstream code—update any direct references.
    • Route parameter parsing options now enforce stricter type constraints; adjust custom parsing handlers to match the tighter validation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aaae082b-2680-4f77-b7fd-c432d73d9a80

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf0e0c and 8129b42.

📒 Files selected for processing (1)
  • packages/router-core/src/route.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/router-core/src/route.ts

📝 Walkthrough

Walkthrough

This change removes the ValidateParsedParams conditional type and replaces it with a Constrain-based restriction on params.parse and the deprecated parseParams, constraining their ParseParamsFn signatures to return ResolveParams<TPath, any> | false.

Changes

Cohort / File(s) Summary
Route type definitions
packages/router-core/src/route.ts
Deleted exported ValidateParsedParams type. Updated ParamsOptions<TPath, TParams>['params']['parse'] and deprecated parseParams to use `Constrain<ParseParamsFn<...>, (rawParams: Expand<ResolveParams>) => ResolveParams<TPath, any>

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble at types with careful paws,
out goes a check, in comes Constrain's laws.
Parsers now promise a tidy view,
Resolve or false — concise and true. 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'simplify type' is vague and generic, failing to convey meaningful information about which specific type is being simplified or how the change impacts the codebase. Use a more descriptive title like 'Replace ValidateParsedParams with Constrain-based type validation' or 'Simplify route param type validation using Constrain helper' to clearly indicate the specific type change being made.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 simplify-type

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 1, 2026

View your CI Pipeline Execution ↗ for commit 7cf0e0c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 7m 57s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-01 08:23:34 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Bundle Size Benchmarks

  • Commit: 2c9f5c0e24e3
  • Measured at: 2026-05-01T08:16:33.583Z
  • Baseline source: history:4a1e63f1d123
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.15 KiB 0 B (0.00%) 273.94 KiB 75.70 KiB █▇▇▇▇▇▁▁▁▁▁
react-router.full 90.68 KiB 0 B (0.00%) 285.45 KiB 78.71 KiB ▇█████▁▁▁▁▁
solid-router.minimal 35.38 KiB 0 B (0.00%) 106.25 KiB 31.81 KiB █▇▇▇▇▇▁▁▁▁▁
solid-router.full 40.10 KiB 0 B (0.00%) 120.46 KiB 36.04 KiB █▇▇▇▇▇▁▁▁▁▁
vue-router.minimal 53.15 KiB 0 B (0.00%) 151.39 KiB 47.73 KiB ██████▁▁▁▁▁
vue-router.full 58.28 KiB 0 B (0.00%) 167.56 KiB 52.18 KiB ██████▁▁▁▁▁
react-start.minimal 101.76 KiB 0 B (0.00%) 322.10 KiB 87.97 KiB ██████▁▁▁▁▁
react-start.full 105.19 KiB 0 B (0.00%) 332.43 KiB 90.96 KiB ██████▁▁▁▁▁
react-start.rsbuild.minimal 99.33 KiB 0 B (0.00%) 316.47 KiB 85.46 KiB ████▂▂▁▁▁▁▁
react-start.rsbuild.full 102.63 KiB 0 B (0.00%) 326.90 KiB 88.28 KiB ████▂▂▁▁▁▁▁
solid-start.minimal 49.40 KiB 0 B (0.00%) 152.08 KiB 43.60 KiB █▇▇▇▇▇▁▁▁▁▁
solid-start.full 55.20 KiB 0 B (0.00%) 168.98 KiB 48.51 KiB █▇▇▇▇▇▁▁▁▁▁

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7309

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7309

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7309

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7309

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7309

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7309

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7309

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7309

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7309

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7309

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7309

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7309

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7309

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7309

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7309

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7309

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7309

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7309

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7309

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7309

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7309

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7309

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7309

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7309

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7309

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7309

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7309

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7309

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7309

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7309

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7309

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7309

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7309

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7309

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7309

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7309

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7309

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7309

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7309

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7309

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7309

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7309

commit: 8129b42

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud is proposing a fix for your failed CI:

We restored the ValidateParsedParams helper type and reverted the Constrain wrapping on parse/parseParams in ParamsOptions, which fixes TypeScript build failures across downstream examples and e2e packages. The Constrain<T, U> utility resolves to the union (T extends U ? T : never) | U, which exposes the specific param shape in the union and creates contravariant function parameter incompatibilities when the type is compared across different route specializations. Our approach uses intersection with unknown/never instead, which validates the params type without altering the type's structure.

Warning

We could not verify this fix.

Suggested Fix changes
diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts
index e52db95d06..f660e81266 100644
--- a/packages/router-core/src/route.ts
+++ b/packages/router-core/src/route.ts
@@ -175,30 +175,27 @@ export type ParseParamsFn<in out TPath extends string, in out TParams> = (
   rawParams: Expand<ResolveParams<TPath>>,
 ) => TParams | false
 
+type ValidateParsedParams<TPath extends string, TParams> = [TParams] extends [
+  ResolveParams<TPath, any>,
+]
+  ? unknown
+  : never
+
 export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
   params: TParams,
 ) => ResolveParams<TPath>
 
 export type ParamsOptions<in out TPath extends string, in out TParams> = {
   params?: {
-    parse?: Constrain<
-      ParseParamsFn<TPath, TParams>,
-      (
-        rawParams: Expand<ResolveParams<TPath>>,
-      ) => ResolveParams<TPath, any> | false
-    >
+    parse?: ParseParamsFn<TPath, TParams> & ValidateParsedParams<TPath, TParams>
     stringify?: StringifyParamsFn<TPath, TParams>
   }
 
-  /** 
+  /**
   @deprecated Use params.parse instead
   */
-  parseParams?: Constrain<
-    ParseParamsFn<TPath, TParams>,
-    (
-      rawParams: Expand<ResolveParams<TPath>>,
-    ) => ResolveParams<TPath, any> | false
-  >
+  parseParams?: ParseParamsFn<TPath, TParams> &
+    ValidateParsedParams<TPath, TParams>
 
   /** 
   @deprecated Use params.stringify instead

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally kMRt-pcnb

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 1, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing simplify-type (8129b42) with main (4a1e63f)2

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

  2. No successful run was found on main (2c9f5c0) during the generation of this report, so 4a1e63f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant