-
Notifications
You must be signed in to change notification settings - Fork 641
Description
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!