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

Fields with skip_deserializing not getting exported? #143

Closed
ghost opened this issue Feb 17, 2023 · 6 comments · Fixed by #204
Closed

Fields with skip_deserializing not getting exported? #143

ghost opened this issue Feb 17, 2023 · 6 comments · Fixed by #204

Comments

@ghost
Copy link

ghost commented Feb 17, 2023

Hello!
Thanks for the great crate, I find it very useful!

I'm just wondering if there's a reason why fields marked with #[serde(skip_deserializing)] are getting skipped? I saw in the macro code that this is a deliberate decision, but I fail to see the reasoning behind it.

As exporting types are in essence serializing them, I would logically assume that the bindings would still include those fields.

Best regards!

@carlocorradini
Copy link

Same problem here!

Why this decision? 🙃

@escritorio-gustavo
Copy link
Contributor

Hey @NyxCode, is this intended behavior?

@NyxCode
Copy link
Collaborator

NyxCode commented Jan 24, 2024

@escritorio-gustavo
I think it is, but it's a bit tricky!

My use-case are mostly HTTP APIs. There, I'd want "skip_serializing" to skip the field when my TS is receiving data, and "skip_deserializing" to skip the field if my TS is sending data.

One alternative I can see to the current behaviour (skip if "skip_serializing" or "skip_deserializing" is present) is to just ignore "skip_serializing" and "skip_deserializing" entirely. That's definetely a step forward, since you can then still skip the field with #[ts(skip)], but right now, there's no way to "un-skip" it.

There might be usecases where it'd be nice to get both variants - like in the REST API example above.

@NyxCode
Copy link
Collaborator

NyxCode commented Jan 24, 2024

So I think the best way forward is to just ignore "skip_serializing" and "skip_deserializing" for now. Happy to be convinced of something else tho.

@escritorio-gustavo
Copy link
Contributor

Yeah, the fact that the data can go both from TS to Rust and from Rust to TS makes this a lot more complicated.
As far as I can tell the only way around it is to ignore both attributes as you proposed and rely on #[ts(skip)] and #[serde(skip)], but that is probably a breaking change for a lot of people, so a major version bump is probably required to implement this

@NyxCode
Copy link
Collaborator

NyxCode commented Jan 24, 2024

Agreed!
Let's keep track of changes, e.g in a CHANGELOG.md, so we can create a GitHub release with a migration guide on the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants