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

DuplicateTypeName errors #289

Closed
Pilfer opened this issue Nov 5, 2024 · 2 comments
Closed

DuplicateTypeName errors #289

Pilfer opened this issue Nov 5, 2024 · 2 comments

Comments

@Pilfer
Copy link

Pilfer commented Nov 5, 2024

I have a project that has the following (simplified) directory structure:

  • v1/mod.rs
  • v2/mod.rs
  • v3/mod.rs

Each file has a Foo struct, and the main project file has an enum called Foos that has them each as a variant.

When using specta::export::ts_with_cfg(...), the DuplicateTypeName is thrown because of the multiple implementations.

  • Is there a derive configuration option that allows me to rename the types on the fly?
  • Is there a way to break out these duplicate types into their own typescript modules/namespaces?
  • Is there a way to retain directory and file structure based on the inputs (ex: v1/mod.rs types end up in ts/v1.ts etc)?

After digging through the docs/examples/previous issues, it looks like TypeCollection may be my best option here (and manually writing the {version}.d.ts file) - but at the cost of manually registering every offending DuplicateTypeName (which is ~206 per file at this time).

Does this seem like a sane solution, or am I missing something more obvious?

Thanks!

@oscartbeaumont
Copy link
Member

Is there a derive configuration option that allows me to rename the types on the fly?

You can use #[specta(rename = "SomeName")] on the struct's.

Is there a way to break out these duplicate types into their own typescript modules/namespaces?

Not yet but work is being done - #72

Is there a way to retain directory and file structure based on the inputs (ex: v1/mod.rs types end up in ts/v1.ts etc)?

Same as above. The plan is to make it configurable to either Typescript namespaces or to replicate the directory structure.

@Pilfer
Copy link
Author

Pilfer commented Nov 6, 2024

Hey Oscar, thanks for the response here (and on the Discord)! That all makes perfect sense - thank you.

I'll go ahead and close this issue and watch for progress on #72 :)

@Pilfer Pilfer closed this as completed Nov 6, 2024
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