Repository navigation
Conversation
| function createObjRefExpression(path, objRef) { | ||
| let impureDefaultValueDeclarator; | ||
| let objRefExpression; | ||
| if (path.parentPath?.isAssignmentPattern()) { |
There was a problem hiding this comment.
When can parentPath be null?
There was a problem hiding this comment.
parentPath can be undefined when traverse.hasType is called, but I admit I may be too paranoid here.
| classes | ||
| } = this | ||
| } = props, | ||
| InputPropsOther = babelHelpers.objectWithoutProperties((_props$Global = props.Global, _props$Global !== void 0 ? _props$Global : this), ["classes"]), |
There was a problem hiding this comment.
This is accessing props.Global twice: once for the destructuring, and once here.
There was a problem hiding this comment.
Good point! It seems that this issue has been around for a while. I would suggest we address it in a separate PR.
#10743 is created.
|
@JLHwung It has been almost six months since you wrote this code: I think your review/:heavy_check_mark: would be "valid" because you have a ,uch deeper understanding of how things work now. |
There was a problem hiding this comment.
var {
InputProps: { ...x } = alert(1),
} = { InputProps: {} };This code shouldn't alert 1, but when transpiled it does.
| @@ -0,0 +1,12 @@ | |||
| var _foo, _props$InputProps; | |||
|
|
|||
| const _foo = { | |||
@JLHwung I'm postponing this PR to a different version that 7.9.5 because of the two bugs I reported above 😅
Co-Authored-By: Nicolò Ribaudo <[email protected]>
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit aec3f77:
|
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/26662/ |
In this PR we add support for assignment pattern in transform-object-rest-spread.
When the object pattern is inside an assignment pattern, the memoized reference for both
objRefand theright(default value) ofAssignmentPatternwill be created so that they will only be executed once.