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

Fix #[ts(skip)] in newtype variants #231

Merged
merged 3 commits into from
Feb 10, 2024
Merged

Conversation

NyxCode
Copy link
Collaborator

@NyxCode NyxCode commented Feb 10, 2024

No description provided.

@NyxCode NyxCode marked this pull request as ready for review February 10, 2024 17:13
Comment on lines 120 to 133
if skip {
quote!(format!("{{ \"{}\": \"{}\" }}", #tag, #name))
} else {
let ty = match (type_override, type_as) {
(Some(_), Some(_)) => syn_err!("`type` is not compatible with `as`"),
(Some(type_override), None) => quote! { #type_override },
(None, Some(type_as)) => {
format_type(&syn::parse_str::<Type>(&type_as)?, dependencies, generics)
}
(None, None) => format_type(&unnamed.unnamed[0].ty, dependencies, generics),
};

quote!(format!("{{ \"{}\": \"{}\", \"{}\": {} }}", #tag, #name, #content, #ty))
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timephy This here was the issue: format_type was called outside of the if skip { .. }, adding the content to the dependencies even if the field was to be skipped.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey :)
Great investigation! Thank you for the quick fix - highly appreciated!

@NyxCode NyxCode merged commit 660dedd into main Feb 10, 2024
8 checks passed
@escritorio-gustavo escritorio-gustavo deleted the fix/skip-in-newtype-variants branch February 12, 2024 13:58
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

Successfully merging this pull request may close these issues.

Bug: #[ts(skip)] does not work properly in newtype variants of adjacently or internally tagged enums
2 participants