-
Notifications
You must be signed in to change notification settings - Fork 479
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
Polymorphism #125
Polymorphism #125
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.
Before I can review, please write some docs about it in the readme with examples. So I can understand from the user point of perspective what you tried to achieve.
Ok, I will provide it asap. One question: travis is complaining, but I cannot reproduce it locally, is this a wrong configuration of CI or did I do something wrong? |
Only Node 4 is failing with
Don't care about it, it's already removed from routing-controllers, so I will remove it from here as well. Update: Done, you can merge master into your branch. |
a510218
to
14aff20
Compare
@NoNameProvided I wrote the doc part and rebased the commit. |
@NoNameProvided any thoughts on this already? |
It has been quite some time since I updated. Is there anything left why this does not get integrated? |
Will try to go through the PRs during the easter. :) No promises tho. |
@NoNameProvided Please do not get me wrong. I just wondered if I have to to do something else or if it's just because you are busy (no problem with that, I have that problem for my projects as well). Still I would appreciate it if you have the time during easter :-) |
Hi @janis91, the PR seems to cover only arrays having different type of objects. However a single property can also have a value of different object instance. Maybe my first example mislead-ed. |
@mustafaekim You're right, the PR covers arrays only. But this is because it is already possible to give a function that determines the type based on the given TypeOptions for single properties. The only thing that was missing, was the possibility to differentiate objects inside of an array. But in order to be able to provide multiple discriminator functions also for a single property, I could try to add the logic for this case as well. |
…to convert into different types in case of a single property and for nested objects in arrays
OK thanks. I would prefer adding a property (whos key can be set) to the json (discriminator property) indicating the class type. |
@mustafaekim could you provide an example, I think I am not understanding what you mean. |
That's how you discover the constructor function:
What I propose is, when transforming from class to json, it may be better to add a discriminator property (like __type) to the json so that when we transform back, we can simply check the value of the discriminator property and find the constructor. Your solution may be optional but by default a adding a discriminator property will work well for 99% of cases That's how typedjson, Jackson (Java) work |
@mustafaekim I tried what I think was your idea. Please check it out. |
Hi, I've read the code, it's like the way I was trying to describe. can't the code below topPhoto: Landscape | Portrait | UnderWater; be topPhoto: Photo; ? |
@mustafaekim Well, actually the |
I didnt know that in Typescript if you use the type Photo, you do not get support for tooling. That's interesting. That is not how it works in tooling for other languages. Anyway thank you for clarification. Is there any schedule when this feature will be merged into the core of the library? (@NoNameProvided ) |
Hi Thanks for your time 😍 |
Hello guys. Was this solved? Is it already stable? |
+1 any ETA on this? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Added the possibility to provide an array of discriminator functions in case of an array of different types.
If you have any other proposal for doing this, comment here or in the related ticket: #51