objection.js: 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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Simplify ReturningMethod so that it avoids infinite type recursion Fixes #2277 — committed to inarix/objection.js by deleted user 5 years ago
For the record, I was getting issues with this when downgrading a version of knex to match my objection version after realizing i had version conflicts (a PSA to always use NPM or non legacy yarn to avoid that)
The source of the error was not because of a typescript nor an objection/knex versions issue per say.
The error message is obtuse but it did surround a genuine type error in my calls to things like
insert()andinsertAndFetch(). I was passing a datetime string instead of a JS Date forObjection.Expression<Date>Before
After
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.3Any updates?
@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.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 asreturning(*).Specifically, my query looks like this where
this.Modelis a genericModelClass<MyModel>: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.