Merge branch 'master' into top-secret

# Conflicts:
#	packages/babylon/src/options.js
#	src/acorn/plugins/flow.js
#	src/acorn/src/util.js
This commit is contained in:
Sebastian McKenzie 2015-07-11 21:04:33 +01:00
commit f9498d7a2d
34 changed files with 294 additions and 90 deletions

View File

@ -1,6 +1,6 @@
<p align="center"> <p align="center">
<a href="https://babeljs.io/"> <a href="https://babeljs.io/">
<img alt="babel" src="https://raw.githubusercontent.com/babel/logo/master/logo.png" width="546"> <img alt="babel" src="https://raw.githubusercontent.com/babel/logo/master/babel.png" width="546">
</a> </a>
</p> </p>

View File

@ -18,9 +18,9 @@ program.option("-p, --print [code]", "Evaluate script and print result");
program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook"); program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js,.es,.jsx]"); program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js,.es,.jsx]");
program.option("-r, --stage [stage]", "Enable support for specific ECMAScript stages"); program.option("-r, --stage [stage]", "Enable support for specific ECMAScript stages");
program.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list); program.option("-w, --whitelist [whitelist]", "Whitelist of transformers separated by comma to ONLY use", util.list);
program.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list); program.option("-b, --blacklist [blacklist]", "Blacklist of transformers separated by comma to NOT use", util.list);
program.option("-o, --optional [optional]", "List of optional transformers to enable", util.list); program.option("-o, --optional [optional]", "List of optional transformers separated by comma to enable", util.list);
var pkg = require("../package.json"); var pkg = require("../package.json");
program.version(pkg.version); program.version(pkg.version);

View File

@ -90,8 +90,8 @@ function ExportDeclaration(node, print) {
export function ImportDeclaration(node, print) { export function ImportDeclaration(node, print) {
this.push("import "); this.push("import ");
if (node.isType) { if (node.importKind === "type" || node.importKind === "typeof") {
this.push("type "); this.push(node.importKind + " ");
} }
var specfiers = node.specifiers; var specfiers = node.specifiers;

View File

@ -592,8 +592,10 @@ export default class ClassTransformer {
pushInherits() { pushInherits() {
if (!this.isDerived || this.pushedInherits) return; if (!this.isDerived || this.pushedInherits) return;
// Unshift to ensure that the constructor inheritance is set up before
// any properties can be assigned to the prototype.
this.pushedInherits = true; this.pushedInherits = true;
this.body.push(t.expressionStatement(t.callExpression( this.body.unshift(t.expressionStatement(t.callExpression(
this.file.addHelper("inherits"), this.file.addHelper("inherits"),
[this.classRef, this.superName] [this.classRef, this.superName]
))); )));

View File

@ -15,7 +15,7 @@ export var metadata = {
export var visitor = { export var visitor = {
ImportDeclaration(node, parent, scope, file) { ImportDeclaration(node, parent, scope, file) {
// flow type // flow type
if (node.isType) return; if (node.importKind === "type" || node.importKind === "typeof") return;
var nodes = []; var nodes = [];

View File

@ -41,7 +41,7 @@ export var visitor = {
}, },
ImportDeclaration(node) { ImportDeclaration(node) {
if (node.isType) this.dangerouslyRemove(); if (node.importKind === "type" || node.importKind === "typeof") this.dangerouslyRemove();
}, },
ExportDeclaration() { ExportDeclaration() {

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
var _Foo$prototype$test, _Foo$prototype$test2; var _Foo$prototype$test, _Foo$prototype$test2;
@ -17,8 +19,6 @@ var Test = (function (_Foo) {
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(babelHelpers.slice.call(arguments))); (_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(babelHelpers.slice.call(arguments)));
} }
babelHelpers.inherits(Test, _Foo);
Test.prototype.test = function test() { Test.prototype.test = function test() {
var _Foo$prototype$test3, _Foo$prototype$test4; var _Foo$prototype$test3, _Foo$prototype$test4;

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
@ -9,6 +11,5 @@ var Test = (function (_Foo) {
_Foo.prototype.test.whatever; _Foo.prototype.test.whatever;
} }
babelHelpers.inherits(Test, _Foo);
return Test; return Test;
})(Foo); })(Foo);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
@ -9,8 +11,6 @@ var Test = (function (_Foo) {
_Foo.prototype.test.call(this); _Foo.prototype.test.call(this);
} }
babelHelpers.inherits(Test, _Foo);
Test.test = function test() { Test.test = function test() {
return _Foo.wow.call(this); return _Foo.wow.call(this);
}; };

View File

@ -1,23 +1,25 @@
"use strict"; "use strict";
var BaseController = (function (_Chaplin$Controller) { var BaseController = (function (_Chaplin$Controller) {
babelHelpers.inherits(BaseController, _Chaplin$Controller);
function BaseController() { function BaseController() {
babelHelpers.classCallCheck(this, BaseController); babelHelpers.classCallCheck(this, BaseController);
_Chaplin$Controller.apply(this, arguments); _Chaplin$Controller.apply(this, arguments);
} }
babelHelpers.inherits(BaseController, _Chaplin$Controller);
return BaseController; return BaseController;
})(Chaplin.Controller); })(Chaplin.Controller);
var BaseController2 = (function (_Chaplin$Controller$Another) { var BaseController2 = (function (_Chaplin$Controller$Another) {
babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another);
function BaseController2() { function BaseController2() {
babelHelpers.classCallCheck(this, BaseController2); babelHelpers.classCallCheck(this, BaseController2);
_Chaplin$Controller$Another.apply(this, arguments); _Chaplin$Controller$Another.apply(this, arguments);
} }
babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2; return BaseController2;
})(Chaplin.Controller.Another); })(Chaplin.Controller.Another);

View File

@ -1,12 +1,13 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
_Foo.apply(this, arguments); _Foo.apply(this, arguments);
} }
babelHelpers.inherits(Test, _Foo);
return Test; return Test;
})(Foo); })(Foo);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
var _babelHelpers$get, _babelHelpers$get2; var _babelHelpers$get, _babelHelpers$get2;
@ -17,7 +19,6 @@ var Test = (function (_Foo) {
(_babelHelpers$get2 = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(babelHelpers.slice.call(arguments))); (_babelHelpers$get2 = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(babelHelpers.slice.call(arguments)));
} }
babelHelpers.inherits(Test, _Foo);
babelHelpers.createClass(Test, [{ babelHelpers.createClass(Test, [{
key: "test", key: "test",
value: function test() { value: function test() {

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
@ -9,6 +11,5 @@ var Test = (function (_Foo) {
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).whatever; babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).whatever;
} }
babelHelpers.inherits(Test, _Foo);
return Test; return Test;
})(Foo); })(Foo);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
@ -9,7 +11,6 @@ var Test = (function (_Foo) {
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).call(this); babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
} }
babelHelpers.inherits(Test, _Foo);
babelHelpers.createClass(Test, null, [{ babelHelpers.createClass(Test, null, [{
key: "test", key: "test",
value: function test() { value: function test() {

View File

@ -7,6 +7,8 @@ var Test = function Test() {
}; };
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
@ -14,7 +16,6 @@ var Foo = (function (_Bar) {
this.state = "test"; this.state = "test";
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
@ -11,6 +13,5 @@ var Foo = (function (_Bar) {
var _this = this; var _this = this;
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,10 +1,11 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,12 +1,13 @@
"use strict"; "use strict";
var TestEmpty = (function (_ref) { var TestEmpty = (function (_ref) {
babelHelpers.inherits(TestEmpty, _ref);
function TestEmpty() { function TestEmpty() {
babelHelpers.classCallCheck(this, TestEmpty); babelHelpers.classCallCheck(this, TestEmpty);
babelHelpers.get(Object.getPrototypeOf(TestEmpty.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(TestEmpty.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(TestEmpty, _ref);
return TestEmpty; return TestEmpty;
})((function () { })((function () {
function _class() { function _class() {
@ -17,12 +18,13 @@ var TestEmpty = (function (_ref) {
})()); })());
var TestConstructorOnly = (function (_ref2) { var TestConstructorOnly = (function (_ref2) {
babelHelpers.inherits(TestConstructorOnly, _ref2);
function TestConstructorOnly() { function TestConstructorOnly() {
babelHelpers.classCallCheck(this, TestConstructorOnly); babelHelpers.classCallCheck(this, TestConstructorOnly);
babelHelpers.get(Object.getPrototypeOf(TestConstructorOnly.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(TestConstructorOnly.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(TestConstructorOnly, _ref2);
return TestConstructorOnly; return TestConstructorOnly;
})((function () { })((function () {
function _class2() { function _class2() {
@ -33,12 +35,13 @@ var TestConstructorOnly = (function (_ref2) {
})()); })());
var TestMethodOnly = (function (_ref3) { var TestMethodOnly = (function (_ref3) {
babelHelpers.inherits(TestMethodOnly, _ref3);
function TestMethodOnly() { function TestMethodOnly() {
babelHelpers.classCallCheck(this, TestMethodOnly); babelHelpers.classCallCheck(this, TestMethodOnly);
babelHelpers.get(Object.getPrototypeOf(TestMethodOnly.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(TestMethodOnly.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(TestMethodOnly, _ref3);
return TestMethodOnly; return TestMethodOnly;
})((function () { })((function () {
function _class3() { function _class3() {
@ -53,12 +56,13 @@ var TestMethodOnly = (function (_ref3) {
})()); })());
var TestConstructorAndMethod = (function (_ref4) { var TestConstructorAndMethod = (function (_ref4) {
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
function TestConstructorAndMethod() { function TestConstructorAndMethod() {
babelHelpers.classCallCheck(this, TestConstructorAndMethod); babelHelpers.classCallCheck(this, TestConstructorAndMethod);
babelHelpers.get(Object.getPrototypeOf(TestConstructorAndMethod.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(TestConstructorAndMethod.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
return TestConstructorAndMethod; return TestConstructorAndMethod;
})((function () { })((function () {
function _class4() { function _class4() {
@ -73,12 +77,13 @@ var TestConstructorAndMethod = (function (_ref4) {
})()); })());
var TestMultipleMethods = (function (_ref5) { var TestMultipleMethods = (function (_ref5) {
babelHelpers.inherits(TestMultipleMethods, _ref5);
function TestMultipleMethods() { function TestMultipleMethods() {
babelHelpers.classCallCheck(this, TestMultipleMethods); babelHelpers.classCallCheck(this, TestMultipleMethods);
babelHelpers.get(Object.getPrototypeOf(TestMultipleMethods.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(TestMultipleMethods.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(TestMultipleMethods, _ref5);
return TestMultipleMethods; return TestMultipleMethods;
})((function () { })((function () {
function _class5() { function _class5() {

View File

@ -1,21 +1,23 @@
"use strict"; "use strict";
var BaseController = (function (_Chaplin$Controller) { var BaseController = (function (_Chaplin$Controller) {
babelHelpers.inherits(BaseController, _Chaplin$Controller);
function BaseController() { function BaseController() {
babelHelpers.classCallCheck(this, BaseController); babelHelpers.classCallCheck(this, BaseController);
babelHelpers.get(Object.getPrototypeOf(BaseController.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(BaseController.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(BaseController, _Chaplin$Controller);
return BaseController; return BaseController;
})(Chaplin.Controller); })(Chaplin.Controller);
var BaseController2 = (function (_Chaplin$Controller$Another) { var BaseController2 = (function (_Chaplin$Controller$Another) {
babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another);
function BaseController2() { function BaseController2() {
babelHelpers.classCallCheck(this, BaseController2); babelHelpers.classCallCheck(this, BaseController2);
babelHelpers.get(Object.getPrototypeOf(BaseController2.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(BaseController2.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2; return BaseController2;
})(Chaplin.Controller.Another); })(Chaplin.Controller.Another);

View File

@ -1,11 +1,12 @@
"use strict"; "use strict";
var Test = (function (_Foo) { var Test = (function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() { function Test() {
babelHelpers.classCallCheck(this, Test); babelHelpers.classCallCheck(this, Test);
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(Test.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(Test, _Foo);
return Test; return Test;
})(Foo); })(Foo);

View File

@ -14,14 +14,14 @@ function broken(x) {
if (true) { if (true) {
var _ret = (function () { var _ret = (function () {
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
_inherits(Foo, _Bar);
function Foo() { function Foo() {
_classCallCheck(this, Foo); _classCallCheck(this, Foo);
_get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); _get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments);
} }
_inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,12 +1,13 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments);
this.bar = "foo"; this.bar = "foo";
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
var _temp; var _temp;
@ -9,6 +11,5 @@ var Foo = (function (_Bar) {
foo((_temp = babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this), this.bar = "foo", _temp)); foo((_temp = babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this), this.bar = "foo", _temp));
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
@ -8,6 +10,5 @@ var Foo = (function (_Bar) {
this.bar = "foo"; this.bar = "foo";
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -1,26 +1,28 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, _Foo); babelHelpers.classCallCheck(this, _Foo);
babelHelpers.get(Object.getPrototypeOf(_Foo.prototype), "constructor", this).call(this); babelHelpers.get(Object.getPrototypeOf(_Foo.prototype), "constructor", this).call(this);
} }
babelHelpers.inherits(Foo, _Bar);
var _Foo = Foo; var _Foo = Foo;
Foo = bar(Foo) || Foo; Foo = bar(Foo) || Foo;
return Foo; return Foo;
})(Bar); })(Bar);
var Foo2 = (function (_Bar2) { var Foo2 = (function (_Bar2) {
babelHelpers.inherits(Foo2, _Bar2);
function Foo2() { function Foo2() {
babelHelpers.classCallCheck(this, _Foo2); babelHelpers.classCallCheck(this, _Foo2);
babelHelpers.get(Object.getPrototypeOf(_Foo2.prototype), "constructor", this).call(this); babelHelpers.get(Object.getPrototypeOf(_Foo2.prototype), "constructor", this).call(this);
} }
babelHelpers.inherits(Foo2, _Bar2);
var _Foo2 = Foo2; var _Foo2 = Foo2;
Foo2 = bar(Foo2) || Foo2; Foo2 = bar(Foo2) || Foo2;
return Foo2; return Foo2;

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo(options) { function Foo(options) {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
@ -11,6 +13,5 @@ var Foo = (function (_Bar) {
babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this, parentOptions); babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this, parentOptions);
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -9,12 +9,13 @@ var _ref = React.createElement(
); );
var App = (function (_React$Component) { var App = (function (_React$Component) {
babelHelpers.inherits(App, _React$Component);
function App() { function App() {
babelHelpers.classCallCheck(this, App); babelHelpers.classCallCheck(this, App);
babelHelpers.get(Object.getPrototypeOf(App.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(App.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(App, _React$Component);
babelHelpers.createClass(App, [{ babelHelpers.createClass(App, [{
key: "render", key: "render",
value: function render() { value: function render() {

View File

@ -7,12 +7,13 @@ Object.defineProperty(exports, "__esModule", {
var _store = require("./store"); var _store = require("./store");
var Login = (function (_React$Component) { var Login = (function (_React$Component) {
babelHelpers.inherits(Login, _React$Component);
function Login() { function Login() {
babelHelpers.classCallCheck(this, Login); babelHelpers.classCallCheck(this, Login);
babelHelpers.get(Object.getPrototypeOf(Login.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(Login.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(Login, _React$Component);
babelHelpers.createClass(Login, [{ babelHelpers.createClass(Login, [{
key: "getForm", key: "getForm",
value: function getForm() { value: function getForm() {

View File

@ -1,11 +1,12 @@
"use strict"; "use strict";
var Foo = (function (_Bar) { var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() { function Foo() {
babelHelpers.classCallCheck(this, Foo); babelHelpers.classCallCheck(this, Foo);
babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments);
} }
babelHelpers.inherits(Foo, _Bar);
return Foo; return Foo;
})(Bar); })(Bar);

View File

@ -95,11 +95,12 @@ export function getOptions(opts) {
options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
if (Array.isArray(options.onToken)) { if (Array.isArray(options.onToken)) {
let tokens = options.onToken; let tokens = options.onToken
options.onToken = (token) => tokens.push(token); options.onToken = (token) => tokens.push(token)
}
if (Array.isArray(options.onComment)) {
options.onComment = pushComment(options, options.onComment)
} }
if (Array.isArray(options.onComment))
options.onComment = pushComment(options, options.onComment);
return options; return options;
} }

View File

@ -784,19 +784,19 @@ export default function (instance) {
instance.extend("parseImportSpecifiers", function (inner) { instance.extend("parseImportSpecifiers", function (inner) {
return function (node) { return function (node) {
node.isType = false; node.importKind = "value"
if (this.isContextual("type")) { var kind =
var startPos = this.start, startLoc = this.startLoc; (this.type === tt._typeof ? "typeof" :
var typeId = this.parseIdent(); (this.isContextual("type") ? "type" : null))
if ((this.type === tt.name && this.value !== "from") || this.type === tt.braceL || this.type === tt.star) { if (kind) {
node.isType = true; var lh = this.lookahead()
} else { if ((lh.type === tt.name && lh.value !== "from") || lh.type === tt.braceL || lh.type === tt.star) {
node.specifiers.push(this.parseImportSpecifierDefault(typeId, startPos, startLoc)); this.next()
if (this.isContextual("from")) return; node.importKind = kind
this.eat(tt.comma);
} }
} }
inner.call(this, node);
inner.call(this, node)
}; };
}); });

View File

@ -6728,13 +6728,49 @@ var fbTestFixture = {
end: { line: 1, column: 26 } end: { line: 1, column: 26 }
} }
}, },
isType: true, importKind: 'type',
range: [0, 27], range: [0, 27],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
end: { line: 1, column: 27 } end: { line: 1, column: 27 }
} }
}, },
'import typeof foo from "bar";': {
type: 'ImportDeclaration',
specifiers: [{
type: 'ImportDefaultSpecifier',
local: {
type: 'Identifier',
name: 'foo',
range: [14, 17],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 17 }
}
},
range: [14, 17],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 17 }
}
}],
source: {
type: 'Literal',
value: 'bar',
raw: '"bar"',
range: [23, 28],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 28 }
}
},
importKind: 'typeof',
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'import type {foo, bar} from "baz";': { 'import type {foo, bar} from "baz";': {
type: 'ImportDeclaration', type: 'ImportDeclaration',
specifiers: [{ specifiers: [{
@ -6798,17 +6834,26 @@ var fbTestFixture = {
end: { line: 1, column: 33 } end: { line: 1, column: 33 }
} }
}, },
isType: true, importKind: 'type',
range: [0, 34], range: [0, 34],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
end: { line: 1, column: 34 } end: { line: 1, column: 34 }
} }
}, },
'import type {foo as bar} from "baz";': { 'import type {foo, bar} from "baz";': {
type: 'ImportDeclaration', type: 'ImportDeclaration',
specifiers: [{ specifiers: [{
type: 'ImportSpecifier', type: 'ImportSpecifier',
local: {
type: 'Identifier',
name: 'foo',
range: [13, 16],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 16 }
}
},
imported: { imported: {
type: 'Identifier', type: 'Identifier',
name: 'foo', name: 'foo',
@ -6818,36 +6863,97 @@ var fbTestFixture = {
end: { line: 1, column: 16 } end: { line: 1, column: 16 }
} }
}, },
range: [13, 16],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 16 }
}
}, {
type: 'ImportSpecifier',
local: { local: {
type: 'Identifier', type: 'Identifier',
name: 'bar', name: 'bar',
range: [20, 23], range: [18, 21],
loc: { loc: {
start: { line: 1, column: 20 }, start: { line: 1, column: 18 },
end: { line: 1, column: 23 } end: { line: 1, column: 21 }
} }
}, },
range: [13, 23], imported: {
type: 'Identifier',
name: 'bar',
range: [18, 21],
loc: { loc: {
start: { line: 1, column: 13 }, start: { line: 1, column: 18 },
end: { line: 1, column: 23 } end: { line: 1, column: 21 }
}
},
range: [18, 21],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 21 }
} }
}], }],
source: { source: {
type: 'Literal', type: 'Literal',
value: 'baz', value: 'baz',
raw: '"baz"', raw: '"baz"',
range: [30, 35], range: [28, 33],
loc: { loc: {
start: { line: 1, column: 30 }, start: { line: 1, column: 28 },
end: { line: 1, column: 35 } end: { line: 1, column: 33 }
} }
}, },
isType: true, importKind: 'type',
range: [0, 36], range: [0, 34],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
end: { line: 1, column: 36 } end: { line: 1, column: 34 }
}
},
'import typeof {foo as bar} from "baz";': {
type: 'ImportDeclaration',
specifiers: [{
type: 'ImportSpecifier',
imported: {
type: 'Identifier',
name: 'foo',
range: [15, 18],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 18 }
}
},
local: {
type: 'Identifier',
name: 'bar',
range: [22, 25],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 25 }
}
},
range: [15, 25],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 25 }
}
}],
source: {
type: 'Literal',
value: 'baz',
raw: '"baz"',
range: [32, 37],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 37 }
}
},
importKind: 'typeof',
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
} }
}, },
'import type from "foo";': { 'import type from "foo";': {
@ -6879,7 +6985,7 @@ var fbTestFixture = {
end: { line: 1, column: 22 } end: { line: 1, column: 22 }
} }
}, },
isType: false, importKind: 'value',
range: [0, 23], range: [0, 23],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
@ -6940,7 +7046,7 @@ var fbTestFixture = {
end: { line: 1, column: 29 } end: { line: 1, column: 29 }
} }
}, },
isType: false, importKind: 'value',
range: [0, 30], range: [0, 30],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
@ -6976,13 +7082,49 @@ var fbTestFixture = {
end: { line: 1, column: 37 } end: { line: 1, column: 37 }
} }
}, },
isType: true, importKind: 'type',
range: [0, 38], range: [0, 38],
loc: { loc: {
start: { line: 1, column: 0 }, start: { line: 1, column: 0 },
end: { line: 1, column: 38 } end: { line: 1, column: 38 }
} }
}, },
'import typeof * as namespace from "bar";': {
type: 'ImportDeclaration',
specifiers: [{
type: 'ImportNamespaceSpecifier',
local: {
type: 'Identifier',
name: 'namespace',
range: [19, 28],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 28 }
}
},
range: [14, 28],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 28 }
}
}],
source: {
type: 'Literal',
value: 'bar',
raw: '"bar"',
range: [34, 39],
loc: {
start: { line: 1, column: 34 },
end: { line: 1, column: 39 }
}
},
importKind: 'typeof',
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 40 }
}
},
}, },
'Array Types': { 'Array Types': {
'var a: number[]': { 'var a: number[]': {

View File

@ -0,0 +1,11 @@
class Foo {}
class Bar extends Foo {
methodA(){}
constructor(){
super();
}
methodB(){}
}

View File

@ -0,0 +1,21 @@
"use strict";
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
};
var Bar = (function (_Foo) {
babelHelpers.inherits(Bar, _Foo);
Bar.prototype.methodA = function methodA() {};
function Bar() {
babelHelpers.classCallCheck(this, Bar);
_Foo.call(this);
}
Bar.prototype.methodB = function methodB() {};
return Bar;
})(Foo);