typeshare
typeshare copied to clipboard
#[serde(rename = "_")]
#[derive(Serialize)]
#[serde(rename = "SomethingFoo")]
#[typeshare]
pub enum Foo {
A
}
#[derive(Serialize)]
#[typeshare]
#[serde(tag = "type", content = "value")]
pub enum Parent {
B(Foo),
}
Outputs
export enum SomethingFoo = { A = 'A' }
export type Parent = { type: 'B', value: Foo } // No Foo. Only SomethingFoo
I have a WIP solution for this: https://github.com/1Password/typeshare/pull/210.
Are you using the multiple file output option? If your outputting to a single file this approach works, however in the case of multiple files it assumes, at the moment, your renamed type and reference are both in the same crate scope.
Would you be able to try this out and let me know if it covers your use cases? I created this snapshot test which adds additional reference use cases.