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

Figure out how to handle scenarios where enum variants contain data types with the same name #48

Open
snowsignal opened this issue Jan 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@snowsignal
Copy link
Contributor

If we have an enum that contains a data type with an identical name, the generated code will be ambiguous and throw errors.

Here's an example of code that would cause this problem.

#[typeshare]
struct Variant {}

#[typeshare]
#[serde(tag ="type", content ="content")]
pub enum MyEnum {
    Variant(Variant),
}

One potential workaround is creating type-aliases to resolve the ambiguous typing, but this solution needs further exploration to ensure we won't create further naming conflicts by accident.

@snowsignal snowsignal self-assigned this Jan 9, 2023
@snowsignal snowsignal added the bug Something isn't working label Feb 12, 2023
@ls-ivan-kiselev
Copy link

Maybe you can use config as well?

[typescript.type_mappings]
"Variant" = "AnotherName"

Would that not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants