Open thongxuan opened 3 months ago
Hello @thongxuan,
did you create any issue (or could you find any open issue) for this pr detailing the need for this? If not, could you please describe when would this export be used?
Thank you
This is related to this issue: https://github.com/typestack/class-transformer/issues/815 This is needed for https://github.com/typestack/class-transformer/issues/563
Hello @thongxuan,
did you create any issue (or could you find any open issue) for this pr detailing the need for this? If not, could you please describe when would this export be used?
Thank you
We use defaultMetadataStorage
to get typeMetadata like so:
const typeMeta = classTransformerMetadataStorage.findTypeMetadata(
meta.target,
meta.propertyName,
)
Which is convenient in cases where you have a @Type(() => MyClass)
annotation on a class property, and you want to get the MyClass for instantiation or other purposes, we then can call typeMeta.typeFunction()
to get the MyClass
in this case.
We have generic components that parse a schema maintained in a set of class-validator
and class-transformer
annotated classes, and these components utilize these annotation values to render Vite/React UI components or handle micro-service endpoint logic utilizing routing-controllers.
Having this default metadata storage being exportable would be super helpful! Right now, we have to have it like this:
import { defaultMetadataStorage } from 'class-transformer/cjs/storage.js';
but this may require additional configuration and it would be much better if we can simply just do:
import { defaultMetadataStorage } from 'class-transformer';
and be able to utilize defaultMetadataStorage
where applicable 🙏
Description
This PR exports default metadata storage which allow picking & subclassing class decorated with class-transfomer.
Checklist
Update index.md
)develop
)npm run prettier:check
passesnpm run lint:check
passesFixes
fixes #[issue number], fixes #[issue number]