inversify / InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.
http://inversify.io/
MIT License
11.34k stars 719 forks source link

Circular dependency found #723

Closed pirmax closed 6 years ago

pirmax commented 6 years ago

Hi have a config file for Inversify with bind.

Inversify config:

container.bind<DatabaseRepositoryInterface>(TYPES.DatabaseRepository).to(DatabaseRepository);

I have multiple injection in my repository:

    private userRepository: UserRepositoryInterface;
    private databaseRepository: DatabaseRepositoryInterface;

    constructor(
        @inject(TYPES.DatabaseRepository) databaseRepository: DatabaseRepositoryInterface,
        @inject(TYPES.UserRepository) userRepository: UserRepositoryInterface
    ) {
        this.userRepository = userRepository;
        this.databaseRepository = databaseRepository;
    }

My error:

Serverless: Failure: Circular dependency found: Symbol(CompanyRepository) --> Symbol(DatabaseRepository) --> Symbol(CompanyRepository)

remojansen commented 6 years ago

@pirmax can you please double check if DatabaseRepository has a dependency on CompanyRepository? Also can you please ensure that you are using the latest version of InversifyJS? Thanks

remojansen commented 6 years ago

Closing this issue because of inactivity. Please feel free to create a new issue if you need help again.