@@ -118,11 +118,16 @@ func (s *Struct) RenderToObject(opts *Options, w io.Writer) (err error) {
118118 for _ , f := range s .Fields {
119119 t := f .Type (opts .NoDate , true )
120120 switch {
121+ case t == "number" :
122+ fmt .Fprintf (w , "%sif (this.%s) data.%s = getNumber(this.%s);\n " ,
123+ opts .indents [2 ], f .Name , f .Name , f .Name )
121124 case t == "Date" :
122125 // convert to valid go time
123- fmt .Fprintf (w , "%sif (this.%s) data.%s = this.%s.getTime() / 1000 >>> 0;\n " , opts .indents [2 ], f .Name , f .Name , f .Name )
126+ fmt .Fprintf (w , "%sif (this.%s) data.%s = this.%s.getTime() / 1000 >>> 0;\n " ,
127+ opts .indents [2 ], f .Name , f .Name , f .Name )
124128 case t == f .ValType : // struct
125- fmt .Fprintf (w , "%sif (this.%s) data.%s = this.%s.toObject();\n " , opts .indents [2 ], f .Name , f .Name , f .Name )
129+ fmt .Fprintf (w , "%sif (this.%s) data.%s = this.%s.toObject();\n " ,
130+ opts .indents [2 ], f .Name , f .Name , f .Name )
126131 case f .TsType == "array" && ! f .IsNative ():
127132 fmt .Fprintf (w , "%sif (Array.isArray(this.%s)) data.%s = this.%s.map((v) => v.toObject());\n " ,
128133 opts .indents [2 ], f .Name , f .Name , f .Name )
0 commit comments