From 495a6bfab27eeea07a99da72bc4b124da81b7fb4 Mon Sep 17 00:00:00 2001 From: Moritz Bischof Date: Mon, 12 Feb 2024 18:56:50 +0100 Subject: [PATCH] add test --- ts-rs/tests/generics.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ts-rs/tests/generics.rs b/ts-rs/tests/generics.rs index 048f847..7089f95 100644 --- a/ts-rs/tests/generics.rs +++ b/ts-rs/tests/generics.rs @@ -349,3 +349,33 @@ fn deeply_nested() { }" ); } + +#[test] +fn inline_generic_enum() { + #[derive(TS)] + struct SomeType(String); + + #[derive(TS)] + enum MyEnum { + VariantA(A), + VariantB(B) + } + + #[derive(TS)] + struct Parent { + e: MyEnum, + #[ts(inline)] + e1: MyEnum + } + + // This fails! + // The #[ts(inline)] seems to inline recursively, so not only the definition of `MyEnum`, but + // also the definition of `SomeType`. + assert_eq!( + Parent::decl(), + "type Parent = { \ + e: MyEnum, \ + e1: { \"VariantA\": number } | { \"VariantB\": SomeType }, \ + }" + ); +} \ No newline at end of file