Skip to content

Commit

Permalink
Add extra test for optional_fields = nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-shigueo committed Dec 1, 2024
1 parent f72238f commit 21d03f5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ts-rs/tests/integration/optional_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,28 @@ fn struct_optional() {
)
)
}

#[derive(TS)]
#[ts(export, export_to = "optional_field/", optional_fields = nullable)]
struct NullableStruct {
a: Option<i32>,
b: Option<i32>,

#[ts(optional = nullable)]
c: Option<i32>,

d: i32,

e: Foo,
f: Bar<i32>,
}

#[test]
fn struct_nullable() {
assert_eq!(
NullableStruct::inline(),
format!(
"{{ a?: number | null, b?: number | null, c?: number | null, d: number, e?: number | null, f?: number | null, }}"
)
)
}

0 comments on commit 21d03f5

Please sign in to comment.