Akryum / peeky

A fast and fun test runner for Vite & Node 🐈️ Powered by Vite ⚡️
https://peeky.dev
MIT License
681 stars 17 forks source link

Circular dependency detected #45

Open mdbetancourt opened 2 years ago

mdbetancourt commented 2 years ago

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

Akryum commented 2 years ago

Because there is a circular dependency between the two files?

Try using import type instead of import

mdbetancourt commented 2 years ago

:( 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;
}