-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Fix decorator options mutating (fixes #55) #60
Conversation
When a class has n properties using the same subclass, the function `baseProp` is called n times for each property in subclass. The function `baseProp` receives a parameter `rawOptions` which should be copied as its being mutated later on. This is intended with the statement: ``` rawOptions = Object.assign(rawOptions, {}) ``` Although, this statement never changes the reference of `rawOptions` with as result that the options are mutating. This causes the final schema to be constructed without the options ref, itemsRef, refPath, etc when the subclass is used more than once. This commit fixes the mutation of the options. Signed-off-by: Chris Lahaye <dev@chrislahaye.com>
one question before i merge: PS: could you update the branch to the latest master? |
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.
only the one question i want answered before i merge, otherwise it looks good, thanks for pointing this reference thing out (I still dont understand what happened there)
@RyannGalea does this pr fix your issue? |
I have not tested this yet, I am hoping so! |
I will merge master and move the assignment.
You could place it before the buildSchema between line 55 and 56, but the original statement that was intended to copy the object was also place afterwards. Regarding the name consistency, you suggest naming the parameter back to
The passed function in
Assume parameter What we would like is the following. Assume parameter This is what happened before this commit. Assume parameter |
Signed-off-by: Chris Lahaye <dev@chrislahaye.com>
with that i meant the below statement for
i mean i dont understand why in this should have the previous pointer, i mean like it is a differing function call and anyway when this fixes these issues, i will merge it, even if i dont understand how these issues were caused |
When a class has n properties using the same subclass, the
function
baseProp
is called n times for each property in subclass.The function
baseProp
receives a parameterrawOptions
whichshould be copied as its being mutated later on. This is intended with
the statement:
Although, this statement never changes the reference of
rawOptions
with as result that the options are mutating. This causes the final schema
to be constructed without the options ref, itemsRef, refPath, etc when
the subclass is used more than once.
This commit fixes the mutation of the options.
Signed-off-by: Chris Lahaye dev@chrislahaye.com