After update to VSCode August 2019 (version 1.38) and Typescript 3.6 i'm getting a lot of Type instantiation is excessively deep and possibly infinite.ts(2589) on TypeORM repository initialization.
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); // only here cast the error above
}
}
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>
There also is the "Excessive stack depth comparing types 'FindConditions<?>' and 'FindConditions<?>' error on the same line.
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:If your workspace have
3.6.xor greater, install a previous version typingnpm install [email protected]Then, with a
.tsfile opened, a typescript version selector will appear on status bar. (version^3.6.xprobably being displayed)then choose "Use Workspace Version" instead of "VS Code's Version"
Be sure that workspace version is also lower than
3.6.xex here version3.4.3is on my workspace. Or else force install a previous version as previouly mentionedNow that version
^3.4.xis selected, you should not have this kind of error on VS Code nortsccommands.Note: Since workspace Typescript version is compatible with TypeORM, running scripts like
npm run buildshould not throw any errors cause it will use Typescript workspace binaries. The errors will only occurs on VS Code or directtsccommands on terminal