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

[Discussion] Plans to support duplicate type names? #62

Open
ajmcquilkin opened this issue Apr 11, 2023 · 3 comments · May be fixed by #72
Open

[Discussion] Plans to support duplicate type names? #62

ajmcquilkin opened this issue Apr 11, 2023 · 3 comments · May be fixed by #72
Labels
help wanted Extra attention is needed
Milestone

Comments

@ajmcquilkin
Copy link

Just submitting this to see if there's any plans to support exporting types with duplicate names. I would love to use specta on a project with auto-generated Rust types with significant numbers of duplicate type names. I can imagine a somewhat direct mapping for duplicate type names existing between Rust modules and TypeScript namespaces, although I can't speak to mappings from Rust modules in other languages.

On a side note, in the event that an equivalent of Rust's module system doesn't exist in a given export language target, this could then throw a DuplicateTypeName error when a user attempts to export to this language.

Within the test_duplicate_ty_name test, I could imagine the following to be a valid TypeScript export from the Rust test modules provided:

namespace one {
    const One = { /* ... */ };
}

namespace two {
    const One = { /* ... */ };
}

const Demo = { one: one.One, two: two.One };

I don't have much context on what this would take technically to implement, but I'd be happy to investigate if this is something the project would be interested in.

@oscartbeaumont
Copy link
Member

I would be willing to support this but I would prefer it if using it was a configuration similar to the current handling of bigints with the options Enabled, Error or something like that.

@Brendonovich has been pushing me towards inlining all of the types in rspc to avoid naming as a problem so having this configuration as an enum would make it possible for me to handle that when I come to implement it.

I don't see myself working on this any time soon but a PR would be welcome. Hit me up on Discord or here if you wanna chat more about specifics if you were going to do a PR.

@oscartbeaumont oscartbeaumont added the help wanted Extra attention is needed label Apr 24, 2023
@oscartbeaumont oscartbeaumont added this to the v2.0.0-rc.4 milestone Sep 23, 2023
@Binlogo
Copy link

Binlogo commented Jun 14, 2024

I'm experiencing the same issue with duplicate type names in different Rust modules when using rspc for Rust and TypeScript communication.

I see there's already a draft PR (#72) addressing this, great job, @ajmcquilkin 👍. Could you share the current progress and status? I'd be happy to assist or discuss further to help move this forward.

Thanks.

@oscartbeaumont
Copy link
Member

At this stage it's on me to find some time and get it merged back into main because a lot of stuff has a changed since the PR was opened. Definetly my bad for not getting the PR reviewed and merged ealier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants