Make optional types better optional in typescript

This commit is contained in:
Fabian Stamm
2025-05-28 13:20:03 +02:00
parent c168df8365
commit f4b32f650c

View File

@ -476,9 +476,12 @@ impl<F: Flavour> Compile for TypeScriptCompiler<F> {
for field in definition.fields.iter() {
let typ = Self::type_to_typescript_ext(&field.typ);
let opt = if field.typ.is_optional() { "?" } else { "" };
f.a1(format!(
"public {}: {};",
"public {}{}: {};",
Self::fix_keyword_name(&field.name),
opt,
typ
));
}