question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeORM thwors “Type instantiation is excessively deep and possibly infinite.ts(2589)” error on Repository typing

See original GitHub issue

After update to VSCode August 2019 (version 1.38) and Typescript 3.6 i’m getting a lot of the fallowing error on a TypeORM repository initialization.

Type instantiation is excessively deep and possibly infinite.ts(2589)

There also is the fallowing error on the file.

Excessive stack depth comparing types ‘FindConditions<?>' and 'FindConditions<?>’

import { Connection, Repository, Entity, BaseEntity,  createConnection } from 'typeorm';
    
@Entity()
class MyEntity extends BaseEntity {
    public id: number;
}
    
class Test {
    async test() {
        const connection: Connection = await createConnection();
        const myRepo: Repository<MyEntity> = connection.getRepository(MyEntity); 
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}

How can I ignore or fix them?

  • VSCode v1.38.0 (user setup)
  • Node.js v10.11.0
  • Typescript v3.4.5
  • TypeORM v0.2.18

I also noticed that the error is gone if the typing is removed : Repository<MyEntity>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:29
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
gustfmcommented, Sep 5, 2019

image

Me too.

7reactions
daniel-diacommented, Nov 10, 2019

This can be solved it by using a previous version of Typescript.

First be sure that the typescript version on your workspace “npm” is lower than 3.6. For instance: package.json:

"dependencies": {
    ...
    "typescript": "^3.0.3"
}

If your workspace have 3.6.x or greater, install a previous version typing npm install typescript@3.4.3

Then, with a .ts file opened, a typescript version selector will appear on status bar. (version ^3.6.x probably being displayed)

enter image description here

then choose “Use Workspace Version” instead of “VS Code’s Version”

enter image description here

Be sure that workspace version is also lower than 3.6.x ex here version 3.4.3 is on my workspace. Or else force install a previous version as previouly mentioned

enter image description here

Now that version ^3.4.x is selected, you should not have this kind of error on VS Code nor tsc commands.

Note: Since workspace Typescript version is compatible with TypeORM, running scripts like npm run build should not throw any errors cause it will use Typescript workspace binaries. The errors will only occurs on VS Code or direct tsc commands on terminal

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeORM throws "Type instantiation is excessively deep and ...
TypeORM throws "Type instantiation is excessively deep and possibly infinite.ts(2589)" error on Repository typing.
Read more >
TypeORM throws "Type instantiation is ... - Newbedev
TypeORM throws "Type instantiation is excessively deep and possibly infinite.ts(2589)" error on Repository typing. Update (23 September 2019):.
Read more >
TypeORM throws &quot;Type instantiation is excessively deep ...
typescript - TypeORM throws "Type instantiation is excessively deep and possibly infinite.ts(2589)" error on Repository typing.
Read more >
The config from nestjs - GithubHelp
Try to import ConfigModule in AppModule, and it throws an error. ... 'default') >> Type instantiation is excessively deep and possibly infinite. ts(2589)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found