peeky icon indicating copy to clipboard operation
peeky copied to clipboard

Circular dependency detected

Open mdbetancourt opened this issue 2 years ago • 2 comments

i have two files

// user.model.ts
import { Action } from 'action.model.ts'
export const User = () => ({
   actions: array(() => Action)
})
// action.model.ts
import { User } from 'user.model.ts'
export const Action = () => ({
   user: () => User
})

but throw Circular dependency detected

mdbetancourt avatar Dec 09 '21 12:12 mdbetancourt

Because there is a circular dependency between the two files?

Try using import type instead of import

Akryum avatar Dec 09 '21 13:12 Akryum

:( i wanna use this test runner for a server side code with relations (loopback) and i need the metadata provided at runtime (the circular dependency is solved with lazy functions) this way peeky is unusable for me

// customer.ts
class Customer extends Entity {
  // constructor, properties, etc.
  @hasMany(() => Order, {keyTo: 'customerId'})
  orders?: Order[];
}
// order.ts
@model()
export class Order extends Entity {
  @belongsTo(() => Customer)
  customerId: number;
}

mdbetancourt avatar Dec 10 '21 00:12 mdbetancourt