objection.js
objection.js copied to clipboard
TypeScript 4.7 Upgrade results in "Type instantiation is excessively deep and possibly infinite."
This is a followup to issue #1668, which seems to resurface with the latest TypeScript (4.7 RC1) upgrade.
Queries of type
await this.$query()
.patch({
...update
})
.returning('*')
Result in TS error TS2589: Type instantiation is excessively deep and possibly infinite..
It appears it is related to this.$query() type of queries, and particularly to .returning('*'). The model class used in the app is of type export class WorkPlan extends RescommsModel (where RescommsModel is of type export class RescommsModel extends Model), but it appears that inheriting directly from Objection Model does not make any difference.
Note: This might well be specific to the fact TypeScript 4.7 being a release candidate and still having some bugs, but I wonder if somebody more versed in TypeScript complex type inference could tell if that were the case.
@laurisvan Did you manage to solve this?
My PR #2278 seems to solve the issue.
Any updates?
Been running into this same issue as well. Specifically when using returning(*) from a $query().
any update or any news here?
Running into this issue as well. Anyone have a solution?
Same thing happens with typescript 4.7.x. But the issue is no longer reproduced in typesciprt 4.8.3. seems to have been resolved.
Same thing happens with typescript 4.7.x. But the issue is no longer reproduced in typesciprt 4.8.3. seems to have been resolved.
unfortunately, no change in my case in typescript 4.8.3, still getting same amount of TS2589: Type instantiation is excessively deep and possibly infinite. errors, as in 4.7.3
But the issue is no longer reproduced in typesciprt 4.8.3. seems to have been resolved.
I'm also encountering this issue with latest typescript 4.9.5 and objection 2.2.18. Occurs in a query using both first() as well as returning(*).
Specifically, my query looks like this where this.Model is a generic ModelClass<MyModel>:
this.Model.query()
.patch({ updatedBy })
.returning('*')
.where('id', id)
.first()
Could somebody provide a reproducible example similar to the one provided in https://github.com/Vincit/objection.js/issues/2132#issuecomment-962988859
I have tried to reproduce this issue but have failed. This may be working now due to the change in 2cefc7735a67a6a840952c407d2a4589cc4d77ba
If somebody could test and confirm, or provide an example if the problem remains, that would be great, thanks!
Hi @lehni, I am still experiencing this issue with the latest versions, i.e. [email protected] and [email protected]. I realised my example was not sufficient, apologies. I've created a reproduction repository here: https://github.com/ahilke/objection-reproduce-2277
@ahilke I wasn't talking of the latest released version. I have since merged some TS fixes and am curious to see if they help with this. Could you install objection from master in your repo and test? e.g. following https://www.pluralsight.com/guides/install-npm-packages-from-gitgithub
@lehni Oh, sorry, didn't realise those changes were not released yet. I've installed master (commit 9b92eb11d1f9278d4c58f0cfb820757f9e65eeea), but still experience the same error. Updated the repo accordingly.
Alright, thanks for the heads up! I'd say let's merge this and be done with it :)