Import of type used in inlined generic type generated
jiftoo opened this issue · 0 comments
jiftoo commented
Hi. I noticed a bug or a limitation of this library. Consider this example:
use std::collections::HashMap;
use ts_rs::TS;
#[derive(TS)]
#[ts(export)]
pub struct Foo {
#[ts(inline)]
map: HashMap<usize, Bar>,
}
#[derive(TS)]
struct Bar {
#[ts(inline)]
map: HashMap<usize, Baz>,
}
#[derive(TS)]
struct Baz {
#[ts(inline)]
map: HashMap<usize, String>,
}
The .ts file produced by this snippet contains an import type
statement referring to the first flattened generic type (Bar
in this case), which is not used anywhere. No other imports are generated. Tested with Vec
and HashMap
.
import type { Bar } from "./Bar";
export interface Foo { map: Record<number, { map: Record<number, { map: Record<number, string>, }>, }>, }
The expected output should not include the first line. Please correct me if I'm missing something from the docs.