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

[feature request] Honour #[serde(rename = "...")] in the generated TypeScript types #42

Open
Starwort opened this issue Sep 3, 2023 · 2 comments

Comments

@Starwort
Copy link

Starwort commented Sep 3, 2023

I have a type which looks like the following:

#[tsync]
#[derive(SomeDieselStuff, Serialize)]
pub struct Foo {
    pub field1: Type1,
    pub field2: Type2,
    #[serde(rename = "type")]
    pub type_: FooType, // called type_ to avoid diesel errors caused by using r#type
    // although as it turns out r#type is also not handled by tsync
}

In the generated output, I get an interface containing type_ and not containing type, where I would expect the interface to contain type instead of type_.

This should probably have its own issue, but using r#type causes the same issue - the generated typescript output would then contain a member called r#type (which is a syntax error in TypeScript, aside from simply being wrong - serde serialises this without the r# as would be expected by the identifier parsing rules)

@Wulf
Copy link
Owner

Wulf commented Sep 3, 2023

hey @Starwort, thanks for reporting this. I currently don’t have time to implement this but I’d welcome any PR. Let me know if I can explain any parts of the code.

@Wulf
Copy link
Owner

Wulf commented Sep 3, 2023

The r# is a great catch btw and it’s probably worth adding a test to catch that

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