-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Specta silently overwrites types defined with duplicate names #101
Comments
A quick fix should be to add |
hmm, .query("posts", |t| {
#[derive(Type, Deserialize, Debug)]
#[specta(inline)]
struct PostsInput {
#[specta(optional)]
offset: Option<u32>,
#[specta(optional)]
count: Option<u32>,
}
t(|db, input: PostsInput| async move {
// ...
})
}) yields: export type Procedures = {
queries:
{ key: "posts", input: PostsInput, result: /* ... */ }
// ...
mutations: never,
subscriptions: never
};
export interface PostsInput { offset?: number, count?: number } which is the same output as when the attribute isn't present. I'm using [email protected] but it looks like there's been significant work on the main branch since then... maybe something was fixed? |
It's possible that isn't in the latest release. I am a bit behind on releasing changes because there are some breaking changes on main which I haven't decided what my plan is with them, once I'm happy with that stuff I will do a release. If you want to try main ensure you also upgrade your frontend packages (I publish beta releases to npm every commit). You will probably wanna refer to the examples for the newer syntax when defining the rspc client on the frontend because the transports system has been replaced with a tRPC style links system. Sorry for the inconvenience! It's also entirely possible rspc is just overriding the inline, I can't remember how it works off the top of my head. |
No worries! This isn't a huge issue for me since it's easy enough to stick to a more explicit naming convention that avoids clashes for now -- happy to wait for a new release. |
I've been using a pattern like this when defining a router:
Rust is totally fine with defining structs in a lexical scope like this -- and since I don't use them anywhere else in my code, it feels ergonomic to colocate them next to the procedure definition.
Specta doesn't mind this either -- but unfortunately, when multiple structs have the same name (as with
Input
above) it'll silently pick one to emit and ignore the rest. This was pretty confusing to me -- I think maybe it should just panic if it encounters an existing name instead?The text was updated successfully, but these errors were encountered: