#![allow(dead_code, clippy::box_collection)] use std::borrow::Cow; use ts_rs::TS; #[test] fn newtype() { #[derive(TS)] struct Newtype(Vec>); assert_eq!(Newtype::inline(), "Array"); } #[test] fn newtype_nested() { #[derive(TS)] struct Newtype(Vec>); assert_eq!(Newtype::inline(), "Array>"); } #[test] fn alias() { type Alias = Vec; assert_eq!(Alias::inline(), "Array"); } #[test] fn alias_nested() { type Alias = Vec>; assert_eq!(Alias::inline(), "Array>"); } #[test] fn named() { #[derive(TS)] struct Struct { a: Box>, b: (Vec, Vec), c: [Vec; 3], } assert_eq!( Struct::inline(), "{ a: Array, b: [Array, Array], c: Array>, }" ); } #[test] fn named_nested() { #[derive(TS)] struct Struct { a: Vec>, b: (Vec>, Vec>), c: [Vec>; 3], } assert_eq!(Struct::inline(), "{ a: Array>, b: [Array>, Array>], c: Array>>, }"); } #[test] fn tuple() { #[derive(TS)] struct Tuple(Vec, (Vec, Vec), [Vec; 3]); assert_eq!( Tuple::inline(), "[Array, [Array, Array], Array>]" ); } #[test] fn tuple_nested() { #[derive(TS)] struct Tuple( Vec>, (Vec>, Vec>), [Vec>; 3], ); assert_eq!( Tuple::inline(), "[Array>, [Array>, Array>], Array>>]" ); }