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
Preserve null in babel-types' clone and deepClone. #4853
Conversation
Current coverage is 89.36% (diff: 100%)
|
Cool - what about a test case for a node that contains null for deepClone and I assume undefined is good? |
I would add your original test case in the tests? |
Adding tests. Updating last test to reflect original test case [,0]
Thanks for the feedback! I updated the implementation to also handle undefined, and added tests for top-level undefined and nested explicit null. However, I don't think there is any valid nested place for undefined --- if you know one, I could add a test for it. Otherwise, as far as I know, null is really the only special value where things went wrong before. |
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.
lgtm
Awesome! Thanks for contributing 👌 |
* Preserve null in babel-types' clone and deepClone. * Also respect undefined when cloning. * Updating last test to reflect original test case "[,0]"
Preserve null in babel-types' clone and deepClone.
(The current behavior turns null into {}, which is not equivalent. Null is a valid expression used to represent missing array elements. The Printer in particular cannot generate code for {}, but it does handle null.)
Add tests.