-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
types: automatically infer discriminator type #15547
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
Conversation
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.
Pull Request Overview
This PR fixes issue #15535 by implementing automatic type inference for discriminator schemas. The main purpose is to enhance TypeScript support by allowing the discriminator function to automatically combine schema generics and return the properly typed discriminator model.
- Adds a new test case demonstrating proper type inference for discriminator models with parent and child schemas
- Updates TypeScript instantiation limits to accommodate the enhanced type checking complexity
- Upgrades TypeScript version in benchmarks to support the new type inference features
Reviewed Changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/types/discriminator.test.ts | Adds comprehensive test case for automatic discriminator type inference using expectType assertions |
scripts/tsc-diagnostics-check.js | Increases maximum TypeScript instantiation limit from 275,000 to 280,000 |
benchmarks/typescript/simple/package.json | Updates TypeScript dependency from 5.5.x to 5.8.x |
Comments suppressed due to low confidence (1)
@hasezoey can you take another look? I did some performance refactoring to reduce and offset the additional instantiations introduced by this PR. |
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.
Still looks good to me.
Fix #15535
Summary
Add a
discriminator()
function override that automatically infers the returned schema type from TypeScript types by combining the schema generics.Examples