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

feat(es/minifier): new Array #4932

Merged
merged 6 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ for (const i of [
1,
2,
3
])if (2 === i) throw new Error('ERR');
])if (2 === i) throw Error('ERR');
console.log(i);
} catch (err) {
console.log('E %s %s', i, err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try {
1,
2,
3
][Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0)if (_step1.value, 2 === i) throw new Error("ERR");
][Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0)if (_step1.value, 2 === i) throw Error("ERR");
} catch (err) {
_didIteratorError1 = !0, _iteratorError1 = err;
} finally{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var A;
!function(A1) {
var beez;
A1.beez2 = new Array(), A1.beez = beez;
A1.beez2 = Array(), A1.beez = beez;
}(A || (A = {}));
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import _class_call_check from "@swc/helpers/lib/_class_call_check.js";
"use strict";
_class_call_check(this, B);
};
A1.beez2 = new Array(), A1.beez = beez;
A1.beez2 = Array(), A1.beez = beez;
}(A || (A = {}));
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Wagon.circle = function(wagons) {
};
var db = new class extends Wagon {
load(files, format) {
if ("xmlolololol" === format) throw new Error("please do not use XML. It was a joke.");
if ("xmlolololol" === format) throw Error("please do not use XML. It was a joke.");
super.speed(), super.weight();
}
constructor(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var Sql = function(Wagon1) {
return _class_call_check(this, Sql), (_this = _super.call(this)).foonly = 12, _this;
}
return Sql.prototype.load = function(files, format) {
if ("xmlolololol" === format) throw new Error("please do not use XML. It was a joke.");
if ("xmlolololol" === format) throw Error("please do not use XML. It was a joke.");
_get(_get_prototype_of(Sql.prototype), "speed", this).call(this), _get(_get_prototype_of(Sql.prototype), "weight", this).call(this);
}, Sql;
}(Wagon), db = new Sql();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import _async_to_generator from "@swc/helpers/lib/_async_to_generator.js";
let maybeNumber;
maybeNumber = 1, ++maybeNumber, maybeNumber++;
let test;
if (!test) throw new Error('Test is not defined');
if (!test) throw Error('Test is not defined');
test.slice(1);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var maybeNumber, test;
import _async_to_generator from "@swc/helpers/lib/_async_to_generator.js";
import regeneratorRuntime from "regenerator-runtime";
if (maybeNumber = 1, ++maybeNumber, maybeNumber++, !test) throw new Error("Test is not defined");
if (maybeNumber = 1, ++maybeNumber, maybeNumber++, !test) throw Error("Test is not defined");
test.slice(1);
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ function f15(x) {
f15({
value: 10
}), f15({
error: new Error("boom")
error: Error("boom")
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ function f15(x) {
f15({
value: 10
}), f15({
error: new Error("boom")
error: Error("boom")
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function assertNever(x, msg) {
throw new Error("Unexpected " + msg);
throw Error("Unexpected " + msg);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function assertNever(x, msg) {
throw new Error("Unexpected " + msg);
throw Error("Unexpected " + msg);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
!function(x) {
return x;
}(()=>{}, 1), new Function();
}(()=>{}, 1), Function();
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ var C = function() {
"use strict";
_class_call_check(this, C2);
};
new Function();
Function();
Original file line number Diff line number Diff line change
@@ -1 +1 @@
new Function();
Function();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var C = function() {
"use strict";
_class_call_check(this, C);
};
new Function();
Function();
var C2 = function() {
"use strict";
_class_call_check(this, C2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function Vec(len) {
this.storage = new Array(len);
this.storage = Array(len);
}
Vec.prototype = {
dot (other) {
if (other.storage.length !== this.storage.length) throw new Error("Dot product only applicable for vectors of equal length");
if (other.storage.length !== this.storage.length) throw Error("Dot product only applicable for vectors of equal length");
let sum = 0;
for(let i = 0; i < this.storage.length; i++)sum += this.storage[i] * other.storage[i];
return sum;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _instanceof from "@swc/helpers/lib/_instanceof.js";
export function Vec(len) {
this.storage = new Array(len);
this.storage = Array(len);
}
Vec.prototype = {
dot: function(other) {
if (other.storage.length !== this.storage.length) throw new Error("Dot product only applicable for vectors of equal length");
if (other.storage.length !== this.storage.length) throw Error("Dot product only applicable for vectors of equal length");
for(var sum = 0, i = 0; i < this.storage.length; i++)sum += this.storage[i] * other.storage[i];
return sum;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Test = function() {
}
var _proto = Test.prototype;
return _proto.fail = function(message) {
throw new Error(message);
throw Error(message);
}, _proto.f1 = function(x) {
void 0 === x && this.fail("undefined argument"), x.length;
}, _proto.f2 = function(x) {
Expand Down Expand Up @@ -53,7 +53,7 @@ var MyThrowable = function() {
_class_call_check(this, MyThrowable);
}
return MyThrowable.prototype.throw = function() {
throw new Error();
throw Error();
}, MyThrowable;
}(), SuperThrowable = function(MyThrowable) {
"use strict";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function error(message) {
throw new Error(message);
throw Error(message);
}
(function(cb) {
cb();
Expand All @@ -8,7 +8,7 @@ function error(message) {
}(()=>error("Something failed")), function(cb) {
cb();
}(()=>{
throw new Error();
throw Error();
}), function(cb) {
cb();
}(()=>error("Error callback"));
8 changes: 4 additions & 4 deletions crates/swc/tests/tsc-references/neverType_es5.2.minified.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _class_call_check from "@swc/helpers/lib/_class_call_check.js";
function error(message) {
throw new Error(message);
throw Error(message);
}
var C = function() {
"use strict";
Expand All @@ -9,11 +9,11 @@ var C = function() {
}
var _proto = C.prototype;
return _proto.void1 = function() {
throw new Error();
throw Error();
}, _proto.void2 = function() {
for(;;);
}, _proto.never1 = function() {
throw new Error();
throw Error();
}, _proto.never2 = function() {
for(;;);
}, C;
Expand All @@ -29,7 +29,7 @@ var C = function() {
}), function(cb) {
cb();
}(function() {
throw new Error();
throw Error();
}), function(cb) {
cb();
}(function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runTestCase(function() {
var a = new Array(!1, void 0, null, "0", {
var a = Array(!1, void 0, null, "0", {
toString: function() {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runTestCase(function() {
var a = new Array(!1, void 0, null, "0", {
var a = Array(!1, void 0, null, "0", {
toString: function() {
return 0;
}
Expand Down
Loading