-
Notifications
You must be signed in to change notification settings - Fork 848
Description
When I want to use own container, I call it in my index.ts
import {useContainer} from 'class-validator';
import {Container} from 'typedi';
useContainer(Container);but the problem is, that MetadataStorage in this case will be replaced with a brand new instance of MetadataStorage, because the call of useContainer is made after all annotations have been parsed and my Container from typedi doesn't them yet and wasn't used to collect them. Therefore the conclusion that we can't use MetadataStorage and getContainer, and should exclude it from the getFromContainer .
The problem is caused by decorators from src/decorator/decorators.ts because they use getFromContainer(MetadataStorage) too early, before the very first place where we could call useContainer.
Currently I investigated class-transformer because it doesn't have this issue, looks like it happens because it uses own MetadataStorage without container.
I've created a pull request to fix the issue, please check it and let me know what you think.
Thank you in advance.