Skip to content

Commit e26cd35

Browse files
ZimmerAmr-c
authored andcommitted
Fix default value for class field parameters in constructors
1 parent fe2a647 commit e26cd35

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

schema_salad/typescript_codegen.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,22 @@ def declare_field(
495495
doc_str=doc_to_doc_string(doc, indent_level=1)
496496
)
497497
)
498-
f.write(
499-
" {safename}{optionalstring}: {type}\n".format(
500-
safename=safename,
501-
type=fieldtype.instance_type,
502-
optionalstring=optionalstring,
498+
if fieldname == "class":
499+
f.write(
500+
" {safename}{optionalstring}: {type}\n".format(
501+
safename=safename,
502+
type=fieldtype.instance_type,
503+
optionalstring="?",
504+
)
505+
)
506+
else:
507+
f.write(
508+
" {safename}{optionalstring}: {type}\n".format(
509+
safename=safename,
510+
type=fieldtype.instance_type,
511+
optionalstring=optionalstring,
512+
)
503513
)
504-
)
505-
506514
if self.current_class_is_abstract:
507515
return
508516

0 commit comments

Comments
 (0)