-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(common): apply options to plaintoclass in classserializerinterceptor #12764
base: master
Are you sure you want to change the base?
fix(common): apply options to plaintoclass in classserializerinterceptor #12764
Conversation
fixed issue that with type option which is not already converted, any other option cannot be applied to plainToClass Closes nestjs#12763
Pull Request Test Coverage Report for Build 36d8ee9e-355b-4c7c-afec-7cf9f5073e60
💛 - Coveralls |
const instance = classTransformer.plainToClass( | ||
options.type, | ||
plainOrClass, | ||
options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is intentional. We only passed options
to the classToPlain
function so far - wondering if changing this now wouldn't cause any breaking changes in existing projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I searched plainToClass method in this repository, I found that except example code there is only one use case in validationPipe and it applied option. I think if developer explicitly used option, then any transform methods which is related to that option should use that option, too. If developer wants to apply option to only classToPlain, I think making developer use toPlainOnly option to decorator(for example Expose) is right. In this file, plainToClass is called only when developer used type option to convert type, and in this case applying option to both transform method seems like correct action, so maybe there is no breaking changes.
Anyway to help this get resolved? |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: Closes #12763
What is the new behavior?
options can be applied to plainToClass method too, which is needed for options like exposeDefaultValues.
Does this PR introduce a breaking change?
Other information