Skip to content

Commit

Permalink
improve tests for type overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
NyxCode committed Nov 8, 2021
1 parent ae67b48 commit 773695b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions ts-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ serde-compat = ["ts-rs-macros/serde-compat"]

[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }

[dependencies]
ts-rs-macros = { version = "5.1.0", path = "../macros" }
Expand Down
10 changes: 9 additions & 1 deletion ts-rs/tests/type_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ use std::time::Instant;

use ts_rs::TS;


struct Unsupported<T>(T);
struct Unsupported2;

#[derive(TS)]
struct Override {
a: i32,
#[ts(type = "0 | 1 | 2")]
b: i32,
#[ts(type = "string")]
x: Instant,
#[ts(type = "string")]
y: Unsupported<Unsupported<Unsupported2>>,
#[ts(type = "string | null")]
z: Option<Unsupported2>
}

#[test]
fn test() {
assert_eq!(
Override::inline(),
"{ a: number, b: 0 | 1 | 2, x: string, }"
"{ a: number, b: 0 | 1 | 2, x: string, y: string, z: string | null, }"
)
}

0 comments on commit 773695b

Please sign in to comment.