Fix issue semi-colon gets inserted unnecessarily (#5749)

* Fix issue semi-colon gets inserted unnecessarily

* Simplify if condition a bit
This commit is contained in:
Buu Nguyen 2017-05-19 13:54:51 -07:00 committed by Henry Zhu
parent 2788a914f6
commit c474fd48e1
4 changed files with 13 additions and 6 deletions

View File

@ -17,14 +17,11 @@ var A = function (_B) {
_classCallCheck(this, A);
if (track !== undefined) {
;
var _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this, track));
} else {
;
var _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this));
}return _possibleConstructorReturn(_this);
}
return _possibleConstructorReturn(_this);
}
return A;

View File

@ -0,0 +1 @@
if (true) [a, b] = [b, a];

View File

@ -0,0 +1,6 @@
if (true) {
var _ref = [b, a];
a = _ref[0];
b = _ref[1];
_ref;
}

View File

@ -126,7 +126,10 @@ export function insertAfter(nodes) {
if (Array.isArray(this.container)) {
return this._containerInsertAfter(nodes);
} else if (this.isStatementOrBlock()) {
if (this.node) nodes.unshift(this.node);
// Unshift current node if it's not an empty expression
if (this.node && (!this.isExpressionStatement() || this.node.expression != null)) {
nodes.unshift(this.node);
}
this._replaceWith(t.blockStatement(nodes));
} else {
throw new Error("We don't know what to do with this node type. " +