Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
75 views
in Technique[技术] by (71.8m points)

typescript - TypeORM throws "Type instantiation is excessively deep and possibly infinite.ts(2589)" error on Repository typing

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Update (23 September 2019):

This issue seems to have been fixed in Typescript version 3.6.3.

Source: https://github.com/typeorm/typeorm/issues/3194#issuecomment-529911310


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...