File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -170,9 +170,17 @@ export class TransformOperationExecutor {
170
170
if ( metadata . options && metadata . options . discriminator && metadata . options . discriminator . property && metadata . options . discriminator . subTypes ) {
171
171
if ( ! ( value [ valueKey ] instanceof Array ) ) {
172
172
if ( this . transformationType === TransformationType . PLAIN_TO_CLASS ) {
173
- type = metadata . options . discriminator . subTypes . find ( ( subType ) => subType . name === subValue [ metadata . options . discriminator . property ] ) ;
173
+ type = metadata . options . discriminator . subTypes . find ( ( subType ) => {
174
+ if ( subValue && metadata . options . discriminator . property in subValue ) {
175
+ return subType . name === subValue [ metadata . options . discriminator . property ]
176
+ }
177
+ } ) ;
174
178
type === undefined ? type = newType : type = type . value ;
175
- if ( ! metadata . options . keepDiscriminatorProperty ) delete subValue [ metadata . options . discriminator . property ] ;
179
+ if ( ! metadata . options . keepDiscriminatorProperty ) {
180
+ if ( subValue && metadata . options . discriminator . property in subValue ) {
181
+ delete subValue [ metadata . options . discriminator . property ] ;
182
+ }
183
+ }
176
184
}
177
185
if ( this . transformationType === TransformationType . CLASS_TO_CLASS ) {
178
186
type = subValue . constructor ;
You can’t perform that action at this time.
0 commit comments