simplify type#7309
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change removes the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
|
View your CI Pipeline Execution ↗ for commit 7cf0e0c
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
There was a problem hiding this comment.
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
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
Merging this PR will not alter performance
Comparing Footnotes
|
Summary by CodeRabbit