Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one type can be output when there are multiple structs with the same name. #219

Open
lzyor opened this issue Dec 16, 2024 · 1 comment

Comments

@lzyor
Copy link

lzyor commented Dec 16, 2024

If more than one struct with the same name exists at the same time, only the type of one of them can be output. When structs are defined in different files, sometimes one will be randomly selected for output.

Adding #[serde(rename = “DataA”)] still does this.

use serde::{Deserialize, Serialize};

#[typeshare::typeshare]
#[derive(Serialize, Deserialize)]
#[serde(rename = "DataA")]
pub struct Data {
    pub t: String,
    pub a: u8,
}

pub mod another {
    use serde::{Deserialize, Serialize};

    #[typeshare::typeshare]
    #[derive(Serialize, Deserialize)]
    #[serde(rename = "DataB")]
    pub struct Data {
        pub t: String,
        pub s: String,
    }
}

output:

/*
 Generated by typeshare 1.13.2
*/

export interface DataA {
	t: string;
	a: number;
}

// There should be `DataB` ?

Some libraries, such as sea_orm require model definitions to be named Model. this results in only one of the definitions being output.

@darrell-roberts
Copy link
Member

If your ok with scoping types with the same name into separate crates then you could use the -d, --output-folder option which generates multiple files for each crate. This feature was added in part to support name spacing beyond a single name space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants