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

Type predictions for union types #115

Closed
wants to merge 1 commit into from

Conversation

EnixCoda
Copy link

@EnixCoda EnixCoda commented Jun 5, 2021

This PR provides prediction functions that distinguish union types, which are frequently used in request return values. It works very well in my own use cases.

Usage example (modified examples/database-update-send-email):
image

Should help resolve #92

PS: The added file would look better if printWidth of prettier could be set to larger number than the default 80 :P

@CLAassistant
Copy link

CLAassistant commented Jun 5, 2021

CLA assistant check
All committers have signed the CLA.

@justjake
Copy link
Contributor

justjake commented Jul 9, 2021

This is a nice idea, but closing as we're planning to replace many of the existing hand-authored types with OpenAPI-generated types.

@justjake justjake closed this Jul 9, 2021
@EnixCoda
Copy link
Author

So you will deprecate the union types since generating the types from OpenAPI? If not, I am very curious how would you resolve union types. Looking forward to your progress.

@justjake
Copy link
Contributor

@EnixCoda The types may change a bit as we do the transition, and using an OpenAPI schema may allow us to generate type guard functions as well. For those reasons it doesn’t make sense to accept this changeset at the moment. We can revisit after the new types land.

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.

Can't index a property value by its type when using Typescript
3 participants