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

How to output oneOf for discriminated unions. #101

Closed
justinfagnani opened this issue Feb 13, 2022 · 1 comment
Closed

How to output oneOf for discriminated unions. #101

justinfagnani opened this issue Feb 13, 2022 · 1 comment

Comments

@justinfagnani
Copy link
Collaborator

For a discriminated union it would be more descriptive to use oneOf instead of anyOf. Human readers and non-TS tooling might not be able to tell that because of the interfaces it's not possible to be valid against more than one of the subschemas, so oneOf would be more clear.

Could we get some kind of annotation to put on a union to declare that it's discriminated, or is there some way to directly infer this from the TS compiler's type-checker?

@justinfagnani
Copy link
Collaborator Author

Oops... I was on the wrong tab when I wrote this. I meant it for https://github.com/YousefED/typescript-json-schema

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

No branches or pull requests

1 participant