Skip to content
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 access to "-1" property on nodesOut array. #6582

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -519,20 +519,17 @@ export default function({ types: t }) {
}
}

let tail = null;
const nodesOut = [];
for (const node of nodes) {
const tail = nodesOut[nodesOut.length - 1];
if (
tail &&
t.isVariableDeclaration(tail) &&
t.isVariableDeclaration(node)
) {
if (tail !== null && t.isVariableDeclaration(node)) {
// Create a single compound declarations
tail.declarations.push(...node.declarations);
} else {
// Make sure the original node kind is used for each compound declaration
node.kind = nodeKind;
nodesOut.push(node);
tail = t.isVariableDeclaration(node) ? node : null;
}
}

Expand Down