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

Upgrade to 2.X results in many "TS2589: Type instantiation is excessively deep and possibly infinite." errors #1668

Closed
svrnwnsch opened this issue Jan 28, 2020 · 8 comments

Comments

@svrnwnsch
Copy link

svrnwnsch commented Jan 28, 2020

We upgraded recently our typescript project from 1.6.11 to 2.1.2. Since then we have many Typescript errors: "TS2589: Type instantiation is excessively deep and possibly infinite."

These errors mainly occur in place where we call. await object.$query().update({...}) or await Class.query().select('*', knex.raw('....'))

I guess this has somewhat to do with the new types introduced in version 2. In general the functionality seems to work as before. So we are just ignoring this specific error.
Maybe this issue is somehow related to: microsoft/TypeScript#34933?

We use Typescript: 3.7.5

@svrnwnsch svrnwnsch changed the title Upgrade to 2.0 results in many "TS2589: Type instantiation is excessively deep and possibly infinite." errors Upgrade to 2.X results in many "TS2589: Type instantiation is excessively deep and possibly infinite." errors Jan 28, 2020
@petrdsvoboda
Copy link

I encountered the same problem. Also in typescript 3.7.
I can't provide any small reproduction case as it appears to be a problem only in larger codebases.

@koskimas
Copy link
Collaborator

As this is a typescript bug, there's not much I can do. I could try to find a workaround if I had a way to reproduce this.

@svrnwnsch
Copy link
Author

Looking at this comment I guess that the problem could come from something like, defining two models witch have a reference to each other and if the models look something like:

export class ModelA extends Model {
   modelBs: ModelB[]
}
export class ModelB extends Model {
   modelAs: ModelA[]
}

If I have some more time I might try to test if such a case will create this issue.

@petrdsvoboda
Copy link

I also think this might be the case.

I tried using the new import type syntax from typescript 3.8.

import type ModelA from './ModelA'
export class ModelB extends Model {
   modelAs: ModelA[]
}

Trying if it would help if the references are set only to a type. But that didn't work for me.

@willsoto
Copy link
Contributor

We are having a similar issue in our codebase that only appeared after the 2.x upgrade. The new typings are much improved, but I wonder if it's something related to these typings that is causing these issues.

It could very well be a TypeScript issue, as there is an open bug there, but I wonder if there is something that can be done here to help mitigate the issue?

I did come across this line from another ORM. Wonder if it could help here?

@petrdsvoboda
Copy link

There doesn't seem to be any response on typescript side.

Would it possible to change the objection.js typings? This issue is blocking me to migrate to the objection v2 without major rewrite. I think that willsoto is right.

We are having a similar issue in our codebase that only appeared after the 2.x upgrade. The new typings are much improved, but I wonder if it's something related to these typings that is causing these issues.

Unfortunately I am not sure if I will be able to fix it myself, but I found a PR fixing this issue in other codebase statelyai/xstate#1103.

@willsoto
Copy link
Contributor

willsoto commented Apr 20, 2020

@petrdsvoboda I wouldn't be so sure. This issue was just closed less than a week ago on the TypeScript side. Read the last two comments.

@koskimas
Copy link
Collaborator

koskimas commented Jun 8, 2020

I believe this is now fixed. Please open a new issue if not.

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

4 participants