Skip to content

Commit 221059f

Browse files
committed
make typescript constructor accept both string and Date for a Date property
1 parent ceaffaf commit 221059f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Tool/Tool-typescript.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ end
202202
str *= indent * "}\n"
203203
elseif get_typescript_type(f) == "Date"
204204
str *= indent * "if (_json['$field_name'] != null) {\n"
205-
str *= indent * " " * "this.$field_name = new Date(_json['$field_name']);\n"
205+
str *= indent * " " * "if (_json['refTime'] instanceof Date) {"
206+
str *= indent * " " * " " * "this.$field_name = _json['$field_name'];\n"
207+
str *= indent * " " * "} else {"
208+
str *= indent * " " * " " * "this.$field_name = new Date(_json['$field_name']);\n"
209+
str *= indent * " " * "}"
206210
str *= indent * "}\n"
207211
else
208212
str *= indent * "this.$field_name = _json['$field_name'];\n"

0 commit comments

Comments
 (0)