Add "use strict" directive (#7411)

* #7349
- Add "use strict" directive to transformed class bodies

* Update tests (#7349)

* Add test for program with use strict directive (#7349)

* Update tests (#7349)

* Update source mapping (#7349)

* Add test for parent blockStatement with use strict directive (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Add test for constructor-only class (#7349)

* Constructor only classes are strict, too

But constructor only that use non-simple parameters must use a strict function wrapper.

* Fix test

* Wrapper not needed if class is already strict

* Revert change to lerna.json
This commit is contained in:
Markus Török
2018-04-10 23:33:38 +02:00
committed by Justin Ridgewell
parent fdd0789936
commit 6597a472b3
127 changed files with 410 additions and 23 deletions

View File

@@ -11,6 +11,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio
var List =
/*#__PURE__*/
function (_Array) {
"use strict";
_inheritsLoose(List, _Array);
function List() {

View File

@@ -1,10 +1,14 @@
let Array = function Array() {
"use strict";
babelHelpers.classCallCheck(this, Array);
};
let List =
/*#__PURE__*/
function (_Array) {
"use strict";
babelHelpers.inherits(List, _Array);
function List() {

View File

@@ -17,6 +17,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio
var List =
/*#__PURE__*/
function (_Array) {
"use strict";
_inherits(List, _Array);
function List() {

View File

@@ -1 +1,3 @@
let A = function A() {};
let A = function A() {
"use strict";
};

View File

@@ -1,10 +1,14 @@
let A = function A() {
"use strict";
console.log('a');
};
let B =
/*#__PURE__*/
function () {
"use strict";
function B() {}
var _proto = B.prototype;

View File

@@ -2,11 +2,15 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
let B = function B() {};
let B = function B() {
"use strict";
};
let A =
/*#__PURE__*/
function (_B) {
"use strict";
_inheritsLoose(A, _B);
function A(track) {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -0,0 +1,6 @@
function t() {
"use strict";
class Foo {
method() {}
}
}

View File

@@ -0,0 +1,15 @@
function t() {
"use strict";
var Foo =
/*#__PURE__*/
function () {
function Foo() {}
var _proto = Foo.prototype;
_proto.method = function method() {};
return Foo;
}();
}

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,6 +1,8 @@
var x =
/*#__PURE__*/
function () {
"use strict";
var _proto = x.prototype;
_proto.f = function f() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inheritsLoose(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Child =
/*#__PURE__*/
function (_Base) {
"use strict";
babelHelpers.inheritsLoose(Child, _Base);
function Child() {

View File

@@ -1,6 +1,8 @@
var Child =
/*#__PURE__*/
function (_Base) {
"use strict";
babelHelpers.inheritsLoose(Child, _Base);
function Child() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function () {
"use strict";
function Foo() {}
var _proto = Foo.prototype;

View File

@@ -2,6 +2,8 @@
var C =
/*#__PURE__*/
function () {
"use strict";
function C() {}
var _proto = C.prototype;

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {}
var _proto = Test.prototype;

View File

@@ -0,0 +1,7 @@
"use strict";
class Foo {
method() {
}
}

View File

@@ -0,0 +1,13 @@
"use strict";
var Foo =
/*#__PURE__*/
function () {
function Foo() {}
var _proto = Foo.prototype;
_proto.method = function method() {};
return Foo;
}();

View File

@@ -1,6 +1,8 @@
var BaseController =
/*#__PURE__*/
function (_Chaplin$Controller) {
"use strict";
babelHelpers.inheritsLoose(BaseController, _Chaplin$Controller);
function BaseController() {
@@ -13,6 +15,8 @@ function (_Chaplin$Controller) {
var BaseController2 =
/*#__PURE__*/
function (_Chaplin$Controller$A) {
"use strict";
babelHelpers.inheritsLoose(BaseController2, _Chaplin$Controller$A);
function BaseController2() {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,3 +1,5 @@
var Test = function Test() {
"use strict";
Function.prototype.hasOwnProperty.call(this, "test");
};

View File

@@ -1,6 +1,8 @@
var A =
/*#__PURE__*/
function (_B) {
"use strict";
babelHelpers.inherits(A, _B);
function A() {

View File

@@ -2,6 +2,8 @@ var x = {
Foo:
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inherits(_class, _Foo);
function _class() {

View File

@@ -1,10 +1,14 @@
var A = function A() {
"use strict";
babelHelpers.classCallCheck(this, A);
};
var B =
/*#__PURE__*/
function (_A) {
"use strict";
babelHelpers.inherits(B, _A);
function B() {

View File

@@ -1,6 +1,8 @@
var A =
/*#__PURE__*/
function () {
"use strict";
function A() {
babelHelpers.classCallCheck(this, A);
}

View File

@@ -1,6 +1,8 @@
var Example =
/*#__PURE__*/
function () {
"use strict";
function Example() {}
var _proto = Example.prototype;

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function () {
"use strict";
function Foo(val) {
babelHelpers.classCallCheck(this, Foo);
this._val = val;

View File

@@ -15,12 +15,16 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "unde
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var B = function B() {
"use strict";
_classCallCheck(this, B);
};
var A =
/*#__PURE__*/
function (_B) {
"use strict";
_inherits(A, _B);
function A(track) {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function () {
"use strict";
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}

View File

@@ -1,4 +1,6 @@
var Example = function Example() {
"use strict";
babelHelpers.classCallCheck(this, Example);
var _Example;

View File

@@ -0,0 +1,5 @@
class Foo {
constructor() {
}
}

View File

@@ -0,0 +1,5 @@
var Foo = function Foo() {
"use strict";
babelHelpers.classCallCheck(this, Foo);
};

View File

@@ -1,4 +1,6 @@
var Test = function Test() {
"use strict";
babelHelpers.classCallCheck(this, Test);
this.state = "test";
};
@@ -6,6 +8,8 @@ var Test = function Test() {
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
@@ -21,6 +25,8 @@ function (_Bar) {
}(Bar);
var ConstructorScoping = function ConstructorScoping() {
"use strict";
babelHelpers.classCallCheck(this, ConstructorScoping);
var bar;
{

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Child =
/*#__PURE__*/
function (_Base) {
"use strict";
babelHelpers.inherits(Child, _Base);
function Child() {

View File

@@ -1,6 +1,8 @@
var Child =
/*#__PURE__*/
function (_Base) {
"use strict";
babelHelpers.inherits(Child, _Base);
function Child() {

View File

@@ -1,5 +1,7 @@
var o = {
foo: function foo() {
"use strict";
babelHelpers.classCallCheck(this, foo);
}
};

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -2,6 +2,8 @@
var C =
/*#__PURE__*/
function () {
"use strict";
function C() {
babelHelpers.classCallCheck(this, C);
}

View File

@@ -1,3 +1,5 @@
var Test = function Test() {
"use strict";
babelHelpers.classCallCheck(this, Test);
};

View File

@@ -1,5 +1,6 @@
var MyCtrl = function MyCtrl(a) {
"any directive prologue";
"use strict";
babelHelpers.classCallCheck(this, MyCtrl);
foo;
@@ -8,6 +9,7 @@ var MyCtrl = function MyCtrl(a) {
var MyCtrl2 = function MyCtrl2(a) {
"a";
"b";
"use strict";
babelHelpers.classCallCheck(this, MyCtrl2);
foo;
@@ -15,6 +17,7 @@ var MyCtrl2 = function MyCtrl2(a) {
var MyCtrl3 = function MyCtrl3(a) {
"a";
"use strict";
babelHelpers.classCallCheck(this, MyCtrl3);
foo;

View File

@@ -2,6 +2,8 @@
var Foo =
/*#__PURE__*/
function () {
"use strict";
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}

View File

@@ -1,9 +1,13 @@
var BaseView = function BaseView() {
"use strict";
babelHelpers.classCallCheck(this, BaseView);
this.autoRender = true;
};
var BaseView = function BaseView() {
"use strict";
babelHelpers.classCallCheck(this, BaseView);
this.autoRender = true;
};
@@ -11,6 +15,8 @@ var BaseView = function BaseView() {
var BaseView =
/*#__PURE__*/
function () {
"use strict";
function BaseView() {
babelHelpers.classCallCheck(this, BaseView);
}

View File

@@ -1,6 +1,8 @@
var A =
/*#__PURE__*/
function () {
"use strict";
function A() {
babelHelpers.classCallCheck(this, A);
}

View File

@@ -1,6 +1,8 @@
var TestEmpty =
/*#__PURE__*/
function (_ref) {
"use strict";
babelHelpers.inherits(TestEmpty, _ref);
function TestEmpty() {
@@ -12,6 +14,8 @@ function (_ref) {
}(
/*#__PURE__*/
function () {
"use strict";
function _class() {
babelHelpers.classCallCheck(this, _class);
}
@@ -22,6 +26,8 @@ function () {
var TestConstructorOnly =
/*#__PURE__*/
function (_ref2) {
"use strict";
babelHelpers.inherits(TestConstructorOnly, _ref2);
function TestConstructorOnly() {
@@ -33,6 +39,8 @@ function (_ref2) {
}(
/*#__PURE__*/
function () {
"use strict";
function _class2() {
babelHelpers.classCallCheck(this, _class2);
}
@@ -43,6 +51,8 @@ function () {
var TestMethodOnly =
/*#__PURE__*/
function (_ref3) {
"use strict";
babelHelpers.inherits(TestMethodOnly, _ref3);
function TestMethodOnly() {
@@ -54,6 +64,8 @@ function (_ref3) {
}(
/*#__PURE__*/
function () {
"use strict";
function _class3() {
babelHelpers.classCallCheck(this, _class3);
}
@@ -68,6 +80,8 @@ function () {
var TestConstructorAndMethod =
/*#__PURE__*/
function (_ref4) {
"use strict";
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
function TestConstructorAndMethod() {
@@ -79,6 +93,8 @@ function (_ref4) {
}(
/*#__PURE__*/
function () {
"use strict";
function _class4() {
babelHelpers.classCallCheck(this, _class4);
}
@@ -93,6 +109,8 @@ function () {
var TestMultipleMethods =
/*#__PURE__*/
function (_ref5) {
"use strict";
babelHelpers.inherits(TestMultipleMethods, _ref5);
function TestMultipleMethods() {
@@ -104,6 +122,8 @@ function (_ref5) {
}(
/*#__PURE__*/
function () {
"use strict";
function _class5() {
babelHelpers.classCallCheck(this, _class5);
}

View File

@@ -1,6 +1,8 @@
var BaseController =
/*#__PURE__*/
function (_Chaplin$Controller) {
"use strict";
babelHelpers.inherits(BaseController, _Chaplin$Controller);
function BaseController() {
@@ -14,6 +16,8 @@ function (_Chaplin$Controller) {
var BaseController2 =
/*#__PURE__*/
function (_Chaplin$Controller$A) {
"use strict";
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
function BaseController2() {

View File

@@ -1,6 +1,8 @@
var Test =
/*#__PURE__*/
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Test = function Test() {
"use strict";
babelHelpers.classCallCheck(this, Test);
babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "hasOwnProperty", babelHelpers.assertThisInitialized(this)).call(this, "test");
};

View File

@@ -15,6 +15,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
_inherits(Foo, _Bar);
function Foo() {

View File

@@ -15,6 +15,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
_inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,6 +1,8 @@
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {