-
-
Notifications
You must be signed in to change notification settings - Fork 533
De-duplicate unions. #1069
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
De-duplicate unions. #1069
Conversation
@@ -91489,7 +91489,7 @@ export interface operations { | |||
/** @description The [status](https://docs.github.com/rest/commits/statuses) contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts. */ | |||
required_contexts?: (string)[]; | |||
payload?: OneOf<[{ | |||
[key: string]: unknown | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty nice
Hm, I think this happens to fix #810 as well. Currently, a schema like this: MetaQuote:
oneOf: []
discriminator:
propertyName: meta_serialization_key
mapping: {} generates like so: export interface components {
schemas: {
MetaQuote: ; // error here
};
} Now, we default to export interface components {
schemas: {
MetaQuote: never;
};
} which I believe is what we expect, right? I can add a more specific regression test for this if we want. |
const members = new Set<string>(); | ||
for (const t of types) { | ||
// unknown swallows everything else in the union | ||
if (t === "unknown") return "unknown"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah this is smart! I hadn’t considered this ❤️
} | ||
|
||
// never gets swallowed by anything else, so only return never | ||
// if it is the only member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Really appreciate all your awesome work on this library, and your helpfulness in the issues! I accept your offer to help and have invited you to have maintaner access 🙂. PRs still require approval from another maintainer, but you can at least open PRs and triage issues easier now. Thank you so much! 🙏 |
When you get accept access to this project, I’ll let you merge this one 🙂 |
0045587
to
80fa7af
Compare
Changes
If a union has multiple members that are the same, then we should de-duplicate them.
#1049 (comment)
How to Review
Checklist
examples/
directory updated (if applicable)