-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Controls: Don't set arg in validateOptions if it would be undefined
#15654
Conversation
Nx Cloud ReportCI ran the following commands for commit 039eeda. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
Nx Cloud ReportWe didn't find any information for the current pull request with the commit 039eeda. Check the Getting started section to configure the app. Sent with 💌 from NxCloud. |
@@ -72,7 +72,9 @@ export const combineArgs = (value: any, update: any): Args => { | |||
export const validateOptions = (args: Args, argTypes: ArgTypes): Args => { | |||
return Object.entries(argTypes).reduce((acc, [key, { options }]) => { | |||
if (!options) { | |||
acc[key] = args[key]; | |||
if (key in args) { |
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.
We could also use args[key] !== undefined
, or various other techniques. I honestly don't know what's the right way.
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.
Good catch. I think this is fine and better than checking against undefined. The alternative would be hasOwnProperty, but since we're dealing with plain objects, it doesn't matter.
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.
💯
undefined
.undefined
Controls: Don't set arg in validateOptions if it would be `undefined`
Thank you for fixing this (and back-porting to 6.3)! I was able to remove a bunch of decorators working around this issue. 💥 |
Fixes #15630
Issue:
Code set
args[X] = undefined
if it wasn't already defined. This was made much more obvious by the removal of default values from args.What I did
Ensure the
args
has the key.How to test
Yes, Jest test.