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

Make Schema a discriminated union #296

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

rictic
Copy link
Contributor

@rictic rictic commented Nov 13, 2024

This leverages the type system to better describe the API's requirements for schemas. For example, rather than saying that any schema might have an optional items property, we're able to express that items is required on array schemas and forbidden on all others.

More info on discriminated unions: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions

@rictic rictic force-pushed the discriminated-union-schema branch 2 times, most recently from 14a8662 to f7d75d5 Compare November 13, 2024 06:34
This leverages the type system to better describe the API's requirements for schemas. For example, rather than saying that any schema might have an optional `items` property, we're able to express that `items` is required on array schemas and forbidden on all others.

More info on discriminated unions: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
@junyanxu junyanxu self-requested a review November 14, 2024 17:25
@junyanxu junyanxu merged commit 3004d3b into google-gemini:main Nov 18, 2024
7 checks passed
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.

2 participants