#![allow(unused)] use std::collections::HashMap; use ts_rs::{Config, TS}; #[derive(TS)] #[ts(export, export_to = "issue_168/")] pub struct Foo { map: HashMap, } #[derive(TS)] #[ts(export, export_to = "issue_168/")] pub struct FooInlined { #[ts(inline)] map: HashMap, } #[derive(TS)] #[ts(export, export_to = "issue_168/")] struct Bar { #[ts(inline)] map: HashMap, } #[derive(TS)] #[ts(export, export_to = "issue_168/")] struct Baz { #[ts(inline)] map: HashMap, } #[test] fn issue_168() { let cfg = Config::from_env(); let extension = cfg .import_extension() .map(|ext| format!(".{ext}")) .unwrap_or_default(); assert_eq!( FooInlined::export_to_string(&cfg).unwrap(), "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\ \n\ export type FooInlined = { map: { [key in number]: { map: { [key in number]: { map: { [key in number]: string }, } }, } }, };\n" ); assert_eq!( Foo::export_to_string(&cfg).unwrap(), format!("// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\ import type {{ Bar }} from \"./Bar{extension}\";\n\ \n\ export type Foo = {{ map: {{ [key in number]: Bar }}, }};\n") ); }