madonoharu / tsify

A library for generating TypeScript definitions from rust code.
Apache License 2.0
311 stars 42 forks source link

Invalid references created with `serde(rename = ...)` #43

Open siefkenj opened 9 months ago

siefkenj commented 9 months ago

When serde(rename = ...) is used the exported type is named to the rename value, but if this type is referenced elsewhere, the original name is used.

e.g.

#[derive(Debug, Clone, Serialize, Deserialize, Tsify)]
#[serde(rename = "foo")]
pub struct Foo {
  x: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize, Tsify)]
pub struct Bar {
  foo: Foo,
}

produces

export interface foo {
    x: number;
}

export interface Bar {
    foo: Foo;
}

which refers to a non-existent Foo type.