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

FirstMethod results in Type instantiation is excessively deep and possibly infinite #2637

Open
LiamMartens opened this issue Apr 2, 2024 · 0 comments

Comments

@LiamMartens
Copy link

This is a problem our team ran into in a large-ish project. I have been trying to create a minimal reproduction but have not been able to get it to trigger consistently in a smaller project. Perhaps there are multiple things at play here.

However, I did do some digging and it looks like the problem is in the following type inside of FirstMethod: QB extends ArrayQueryBuilder<QB> ? MaybeSingleQueryBuilder<QB> : QB;. It appears any attempt to create a QB extends conditional type results in infinite recursion (at least in our project). I believe this may be somewhat related to #2277 since they use almost the exact same typing.

I am creating a PR with a proposed fix for this problem which would always return a MaybeSingleQueryBuilder<QB> from the first() function instead of conditionally returning. This appears to solve our problem and remain largely consistent with the current typing. As far as I can tell the only thing that would change is that the following statement: await Model.query().insert().first().fetch() would now return a possibly undefined type as opposed to an always defined type.

I don't feel like this is a problem however since there is really no need to call first() after insert()

Open to feedback of course!

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

No branches or pull requests

1 participant