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

Add support generic bounds #389

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

olegshtch
Copy link
Contributor

@olegshtch olegshtch commented Jul 23, 2019

Allows to use generate extends bound on generic types.

@vojtechhabarta
Copy link
Owner

@olegshtch thanks for this nice PR.
I would wait for more use cases or comments before merging it.

@olegshtch olegshtch force-pushed the generic-bounds branch 2 times, most recently from 837f0c0 to bb80aec Compare September 3, 2019 10:51
@olegshtch
Copy link
Contributor Author

Looks like #380 isn't fixed with this PR.

@olegshtch
Copy link
Contributor Author

Rebased. Removed test for #380.

@vojtechhabarta
Copy link
Owner

@olegshtch I pushed fix for #380 - c231299

@olegshtch
Copy link
Contributor Author

@vojtechhabarta I suppose generic bounds wasn't part of this commit?

@vojtechhabarta
Copy link
Owner

No, I think it is separate thing.

@olegshtch
Copy link
Contributor Author

olegshtch commented Sep 10, 2019

Is something left to do in this PR?

@vojtechhabarta
Copy link
Owner

I am not sure if this feature has high enough value to justify the change in generated output.
Do you have any real example where this feature might be useful?
The feature itself is nice but I think it can potentially break some existing user code.

@olegshtch
Copy link
Contributor Author

We use a narrowing of types in a production Java code so prefer to have it in a TypeScript. Something like Message<T extends Body> where Body have a some guarantied fields.

@olegshtch
Copy link
Contributor Author

Maybe add a new option to enable it?

@vojtechhabarta
Copy link
Owner

In general I prefer not to add new parameters because it is becoming harder for users to go through all typescript-generator parameters.

Currently typescript-generator outputs Message<T> which looses extends Body but then this type is used somewhere with particular type argument, for example:

interface Response {
    message: Message<HumanBody>;
}
interface HumanBody extends Body {
}

So when there is a JSON with Response data it is correctly typed.

@olegshtch olegshtch mentioned this pull request Oct 17, 2019
@olegshtch
Copy link
Contributor Author

Rebased

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