fix: classToPlain provoke "'constructor' of null" error when used on null class members that defines the discriminator option #790
Labels
status: needs triage
Issues which needs to be reproduced to be verified report.
type: fix
Issues describing a broken feature.
Description
Both
classToPlain
andserialize
are provoking the following errorTypeError: Cannot read property 'constructor' of null
when called on classes that have members with the@Type
decorator defining thediscriminator
option and that'snull
orundefined
once initialized.Minimal code-snippet showcasing the problem
Expected behavior
The functions
classToPlain
andserialize
shouldn't treat class members that defines@Type
decorator withdiscriminator
option when they arenull
orundefined
.Actual behavior
The functions
classToPlain
andserialize
fire the following error:TypeError: Cannot read property 'constructor' of null
. It's likely that the logic doesn't verify if there's a value before proceeding with the transformation.The following code snippet (
TransformOperationExecutor.js
, line 209) should verify if there's value before proceeding (perhaps a simple&& subValue
added to the condition does the trick).It's likely that is not the only place where it should be fixed.
The text was updated successfully, but these errors were encountered: