0

I am using inversify for an mean stack application developed with typescript. Following the instructions here at this url: https://www.npmjs.com/package/inversify, I created the inversify.config.ts file and added the code relevant to my needs. I am receiving the following error for one of my binding: "Error:(39, 71) TS2349:Cannot invoke an expression whose type lacks a call signature. Type 'typeof ExampleRepository' has no compatible call signatures.".

inversify.config.ts:
myContainer.bind<IExampleRepository<IGroup>>(TYPES.IExampleRepository).to(ExampleRepository<IGroup>).whenTargetNamed("exampleRepository");

types.ts:
IExampleRepository: Symbol("ExampleRepository")

How would the inversify.config.ts entry have to change to accomodate this need? What am I doing wrong here? Can inversify handle this scenario?

user1790300
  • 2,143
  • 10
  • 54
  • 123

1 Answers1

0

I think that if your interface is generic IExampleRepository<T> then your ExampleRepository doesn't need the <IGroup> generic on it.

import { Container, injectable } from "inversify";


const TYPES = {
    IExampleRepository: Symbol("IExampleRepository"),
};

class IGroup {

}

interface IExampleRepository<T> {
    group: T;
}

@injectable()
class ExampleRepository implements IExampleRepository<IGroup> {
    group: IGroup
}

const myContainer = new Container();
myContainer.bind<IExampleRepository<IGroup>>(TYPES.IExampleRepository).to(ExampleRepository).whenTargetNamed("exampleRepository");

`

Please provide more example code for IExampleRepository and Examplerepository. That might help get a better answer.

AltekkeE
  • 43
  • 1
  • 6