Allow flattening newtypes and as types#477
Open
cairomassimo wants to merge 1 commit intoAleph-Alpha:mainfrom
Open
Allow flattening newtypes and as types#477cairomassimo wants to merge 1 commit intoAleph-Alpha:mainfrom
cairomassimo wants to merge 1 commit intoAleph-Alpha:mainfrom
Conversation
Collaborator
|
Hi @cairomassimo thanks for the PR! We are already making a change (#474) to how we flatten structs with zero fields that touches some of the same areas of the code as you have here - specifically, the match expression in the enum file. Would you mind waiting until those changes are merged as to help us avoid a possible conflict and breaking change? |
Author
|
Sure! The changes to the implementation are small anyway, and the test
won't have any conflicts. Thanks for the quick response
…On Sun, Feb 8, 2026, 21:10 Gustavo Shigueo ***@***.***> wrote:
*gustavo-shigueo* left a comment (Aleph-Alpha/ts-rs#477)
<#477 (comment)>
Hi @cairomassimo <https://github.com/cairomassimo> thanks for the PR! We
are already making a change (#474
<#474>) to how we flatten
structs with zero fields that touches some of the same areas of the code as
you have here - specifically, the match expression in the enum file. Would
you mind waiting until those changes are merged as to help us avoid a
possible conflict and breaking change?
—
Reply to this email directly, view it on GitHub
<#477 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7M2BKCIZ74E5FUCXSK4ET4K6C2BAVCNFSM6AAAAACUMYNAX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQNRYGAYDMNBUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
serde_jsonbehavior.#[ts(as = "...")]if the referenced type can be flattened. This can be useful and (as far as I can tell) has no downsides.Changes
macros/src/types/newtype.rs: Addinline_flattenedthat delegates to the inner typemacros/src/types/type_as.rs: Addinline_flattenedthat delegates to theastypemacros/src/types/enum.rs: Restructure internally tagged enum handling to check for newtype variants first, ensuring they always use intersection syntax ({ "tag": "A" } & Type) rather than the flattened pathnewtype_flatten.rsandtype_as_flatten.rsChecklist