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 2 years ago
  • Reactions: 1
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Any 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.

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()

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

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.