Typeorm error in nestjs ReferenceError: Cannot access ‘A’ before initialization

I have 3 typeorm entities A,B and C . I am using B as a many to many table for A and C. So, I have ManyToOnes in B for A and C. And OneToMany in each of the A and C entities pointing to B. The ReferenceError: Cannot access ‘A’ before initialization. This error disappears when I remove the OneToMany from entity A.

It should run properly as I have used this pattern before.