Skip to content

Commit

Permalink
style(ast_tools): fix wonky formatting (#7288)
Browse files Browse the repository at this point in the history
Follow-on after #7283. Pure refactor. `rustfmt` was malfunctioning on this code for some reason. Alter the code slightly so it formats it nicely.
  • Loading branch information
overlookmotel committed Nov 14, 2024
1 parent f0affa2 commit f0dee76
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tasks/ast_tools/src/generators/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ fn typescript_struct(def: &StructDef, always_flatten_structs: &FxHashSet<TypeId>

let ident = field.ident().unwrap();
if let Some(append_after) = append_to.get(&ident.to_string()) {
let after_type =
if let Some(ty) = &append_after.markers.derive_attributes.estree.typescript_type {
ty.clone()
let ts_type = &append_after.markers.derive_attributes.estree.typescript_type;
let after_type = if let Some(ty) = ts_type {
ty.clone()
} else {
let typ = append_after.typ.name();
if let TypeName::Opt(inner) = typ {
type_to_string(inner)
} else {
let typ = append_after.typ.name();
if let TypeName::Opt(inner) = typ {
type_to_string(inner)
} else {
panic!(
panic!(
"expected field labeled with append_to to be Option<...>, but found {typ}"
);
}
};
}
};

if let Some(inner) = ty.strip_prefix("Array<") {
ty = format!("Array<{after_type} | {inner}");
} else {
Expand Down

0 comments on commit f0dee76

Please sign in to comment.