Skip to content

Commit

Permalink
buggy grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Oct 21, 2023
1 parent 8604116 commit 6eac6f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ impl<T: TS> TS for Option<T> {
"called Option::name_with_type_args with {} args",
args.len()
);
format!("{} | null", args[0])
format!("({} | null)", args[0])
}

fn inline() -> String {
format!("{} | null", T::inline())
format!("({} | null)", T::inline())
}

fn dependencies() -> Vec<Dependency>
Expand All @@ -471,11 +471,11 @@ impl<T: TS, E: TS> TS for Result<T, E> {
"called Result::name_with_type_args with {} args",
args.len()
);
format!("{{ ok: {} }} | {{ err: {} }}", args[0], args[1])
format!("({{ ok: {} }} | {{ err: {} }})", args[0], args[1])
}

fn inline() -> String {
format!("{{ ok: {} }} | {{ err: {} }}", T::inline(), E::inline())
format!("({{ ok: {} }} | {{ err: {} }})", T::inline(), E::inline())
}

fn dependencies() -> Vec<Dependency>
Expand Down
4 changes: 2 additions & 2 deletions ts-rs/tests/optional_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Optional {
#[test]
fn test() {
#[cfg(not(feature = "serde-compat"))]
assert_eq!(Optional::inline(), "{ a?: number, b: string | null, }");
assert_eq!(Optional::inline(), "({ a?: number, b: string | null, })");
#[cfg(feature = "serde-compat")]
assert_eq!(Optional::inline(), "{ a?: number, b?: string, }")
assert_eq!(Optional::inline(), "({ a?: number, b?: string, })")
}
2 changes: 1 addition & 1 deletion ts-rs/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ struct Fallible {
fn test() {
assert_eq!(
Fallible::inline(),
"{ a: { ok: number } | { err: string }, }"
"({ a: { ok: number } | { err: string }, })"
)
}

0 comments on commit 6eac6f1

Please sign in to comment.