InversifyJS icon indicating copy to clipboard operation
InversifyJS copied to clipboard

Error message unclear

Open penguinsAreFunny opened this issue 4 years ago • 0 comments

I got the error "Metadata key was used more than once in a parameter: inject".

You can find the error constant: https://github.com/inversify/InversifyJS/blob/master/src/constants/error_msgs.ts You can find it used: https://github.com/inversify/InversifyJS/blob/master/src/annotation/decorator_utils.ts

I do not understand what this error message means. Can someone explain this error message to me? What is a metadata key?

At this point I am not sure, if the error message is not ideal, if this bug should not occure (at least in my code) at all or if I am only not understanding the error message.

I would really appreciate it, if you could help me understand this error.

My assumptions: If the same class name and static property name occurres twice in one application it will lead to an error.

export class Class1 { @inject(TYPES.property) static property }

somewhere else, f.e. in a node_modules package export class Class1 { @inject(TYPES.property) static property }

Is this correct? Are the Meta-key the class-names + property-names? Therefore probably not unique? If InversifyJS was implemented that way I think this is a mistake as Typescript does support such use cases. If my assumptions are true I think that the keys should not be the class-names + property-names but should be generated.

penguinsAreFunny avatar Oct 14 '21 19:10 penguinsAreFunny