File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -184,12 +184,22 @@ export class TransformOperationExecutor {
184
184
185
185
// get a subvalue
186
186
let subValue : any = undefined ;
187
- if ( value instanceof Map ) {
188
- subValue = value . get ( valueKey ) ;
189
- } else if ( value [ valueKey ] instanceof Function ) {
190
- subValue = value [ valueKey ] ( ) ;
191
- } else {
187
+ if ( this . transformationType === TransformationType . PLAIN_TO_CLASS ) {
188
+ /**
189
+ * This section is added for the following report:
190
+ * https://github.com/typestack/class-transformer/issues/596
191
+ *
192
+ * We should not call functions or constructors when transforming to class.
193
+ */
192
194
subValue = value [ valueKey ] ;
195
+ } else {
196
+ if ( value instanceof Map ) {
197
+ subValue = value . get ( valueKey ) ;
198
+ } else if ( value [ valueKey ] instanceof Function ) {
199
+ subValue = value [ valueKey ] ( ) ;
200
+ } else {
201
+ subValue = value [ valueKey ] ;
202
+ }
193
203
}
194
204
195
205
// determine a type
@@ -254,6 +264,7 @@ export class TransformOperationExecutor {
254
264
propertyName
255
265
) ;
256
266
267
+ console . log ( { reflectedType } ) ;
257
268
if ( reflectedType ) {
258
269
type = reflectedType ;
259
270
}
You can’t perform that action at this time.
0 commit comments