Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zero-schema): Fix an issue with TS2589 #3620

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

arv
Copy link
Contributor

@arv arv commented Jan 27, 2025

TS2589: Type instantiation is excessively deep and possibly infinite

The hint to solve this was here:

microsoft/TypeScript#30188 (comment)

The solution is to compute the types that cause problems step by step. By using T extends infer U, we can force the computation of T instead of deferring it. This way the instantiation does not get deeper.

instantiation is excessively deep and possibly infinite

TS2589: Type instantiation is excessively deep and possibly infinite

The hint to solve this was here:

microsoft/TypeScript#30188 (comment)

The solution is to compute the types that cause problems step by step.
By using `T extends infer U`, we can force the computation of `T`
instead of deferring it. This way the instantiation does not get deeper.

 instantiation is excessively deep and possibly infinite
@arv arv requested a review from tantaman January 27, 2025 12:48
Copy link

vercel bot commented Jan 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
replicache-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 27, 2025 0:50am
zbugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 27, 2025 0:50am

Copy link

github-actions bot commented Jan 27, 2025

🐰 Bencher Report

Brancharv/max-number-of-relations
Testbedlocalhost
Click to view all benchmark results
BenchmarkThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
src/client/zero.bench.ts > basics > All 1000 rows x 10 columns (numbers)📈 view plot
🚷 view threshold
72.04
(-0.57%)
69.86
(96.98%)
src/client/zero.bench.ts > with filter > Lower rows 500 x 10 columns (numbers)📈 view plot
🚷 view threshold
98.67
(+4.63%)
91.64
(92.87%)
🐰 View full continuous benchmarking report in Bencher

@arv arv merged commit 55b27ab into main Jan 27, 2025
11 checks passed
@arv arv deleted the arv/max-number-of-relations branch January 27, 2025 13:37
@arv
Copy link
Contributor Author

arv commented Jan 27, 2025

@tantaman
Copy link
Contributor

🧙‍♂️

Using the TS example:
Reverse<Reverse<T1> extends infer R ? Cast<R, any[]> : never, T2>

So this causes the compiler to figure out the type of Reverse<T1> before passing it to Cast? Whereas the opposite formulation: Reverse<Cast<Reverse<T1>, any[]>, T2> would create a tree of expressions of arbitrary depth to be evaluated?

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.

2 participants