Skip to content

Commit

Permalink
Remove panic
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-shigueo committed Nov 10, 2024
1 parent ad4f024 commit ade6a2f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 0 additions & 12 deletions macros/src/types/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,6 @@ fn format_field(
quote! { "" }
};

let optional_annotation = if let Optional::Optional { .. } = field_attr.optional {
quote! {
if <#ty as #crate_rename::TS>::IS_OPTION {
#optional_annotation
} else {
panic!("`#[ts(optional)]` can only be used with the Option type")
}
}
} else {
optional_annotation
};

if field_attr.flatten {
flattened_fields.push(quote!(<#ty as #crate_rename::TS>::inline_flattened()));
dependencies.append_from(&ty);
Expand Down
2 changes: 2 additions & 0 deletions ts-rs/tests/integration/optional_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ struct OptionalStruct {
#[ts(optional = nullable)]
c: Option<i32>,

// `#[ts(optional)]` on a type that isn't `Option<T>` does nothing
#[ts(optional = nullable)]
d: i32,

e: Foo,
Expand Down

0 comments on commit ade6a2f

Please sign in to comment.