Skip to content

Commit

Permalink
Remove extra methods for option inner type
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-shigueo committed Nov 10, 2024
1 parent 6f064f5 commit ad4f024
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
4 changes: 2 additions & 2 deletions macros/src/types/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn format_field(
if let Optional::Optional { nullable: false } = opt {
quote! {
if <#ty as #crate_rename::TS>::IS_OPTION {
<#ty as #crate_rename::TS>::option_inner_inline().unwrap()
<#ty as #crate_rename::TS>::name().trim_end_matches(" | null").to_owned()
} else {
<#ty as #crate_rename::TS>::inline()
}
Expand All @@ -157,7 +157,7 @@ fn format_field(
if let Optional::Optional { nullable: false } = opt {
quote! {
if <#ty as #crate_rename::TS>::IS_OPTION {
<#ty as #crate_rename::TS>::option_inner_name().unwrap()
<#ty as #crate_rename::TS>::name().trim_end_matches(" | null").to_owned()
} else {
<#ty as #crate_rename::TS>::name()
}
Expand Down
18 changes: 0 additions & 18 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,6 @@ pub trait TS {
#[doc(hidden)]
const IS_OPTION: bool = false;

#[doc(hidden)]
fn option_inner_name() -> Option<String> {
None
}

#[doc(hidden)]
fn option_inner_inline() -> Option<String> {
None
}

/// Identifier of this type, excluding generic parameters.
fn ident() -> String {
// by default, fall back to `TS::name()`.
Expand Down Expand Up @@ -745,14 +735,6 @@ impl<T: TS> TS for Option<T> {
format!("{} | null", T::inline())
}

fn option_inner_name() -> Option<String> {
Some(T::name())
}

fn option_inner_inline() -> Option<String> {
Some(T::inline())
}

fn visit_dependencies(v: &mut impl TypeVisitor)
where
Self: 'static,
Expand Down

0 comments on commit ad4f024

Please sign in to comment.