Merge pull request #5761 from babel/b7-10

Babylon 7 alpha.10
This commit is contained in:
Henry Zhu 2017-05-25 14:29:25 -04:00 committed by GitHub
commit ce2335604c
37 changed files with 312 additions and 13 deletions

View File

@ -32,7 +32,7 @@
"babel-template": "7.0.0-alpha.9",
"babel-traverse": "7.0.0-alpha.9",
"babel-types": "7.0.0-alpha.9",
"babylon": "7.0.0-beta.8",
"babylon": "7.0.0-beta.10",
"convert-source-map": "^1.1.0",
"debug": "^2.1.1",
"json5": "^0.5.0",

View File

@ -1,5 +1,13 @@
export function ClassDeclaration(node: Object) {
this.printJoin(node.decorators, node);
import * as t from "babel-types";
export function ClassDeclaration(node: Object, parent: Object) {
if (
!t.isExportDefaultDeclaration(parent) &&
!t.isExportNamedDeclaration(parent)
) {
this.printJoin(node.decorators, node);
}
this.word("class");
if (node.id) {

View File

@ -52,13 +52,21 @@ export function ExportAllDeclaration(node: Object) {
this.semicolon();
}
export function ExportNamedDeclaration() {
export function ExportNamedDeclaration(node: Object) {
if (t.isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
}
this.word("export");
this.space();
ExportDeclaration.apply(this, arguments);
}
export function ExportDefaultDeclaration() {
export function ExportDefaultDeclaration(node: Object) {
if (t.isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node);
}
this.word("export");
this.space();
this.word("default");

View File

@ -9,6 +9,7 @@ declare class A<T> extends B<T> { x: number }
declare class A { static foo(): number; static x : string }
declare class A { static [ indexer: number]: string }
declare class A { static () : number }
declare class B { (): number }
declare class A mixins B<T>, C {}
declare type A = string
declare type T<U> = { [k:string]: U }

View File

@ -9,6 +9,7 @@ declare class A<T> extends B<T> { x: number }
declare class A { static foo: () => number, static x: string, }
declare class A { static [indexer: number]: string }
declare class A { static (): number }
declare class B { (): number }
declare class A mixins B<T>, C {}
declare type A = string;
declare type T<U> = { [k: string]: U };

View File

@ -0,0 +1 @@
({ set = {} }) => set;

View File

@ -0,0 +1 @@
({ set = {} }) => set;

View File

@ -3,6 +3,7 @@ class Foo {
foo = 1;
"foo";
"foo" = 1;
foo = super.foo();
["foo"];
["foo"] = 1;
["f" + "oo"];
@ -12,8 +13,56 @@ class Foo {
static foo = 1;
static "foo";
static "foo" = 1;
static foo = super.foo();
static ["foo"];
static ["foo"] = 1;
static ["f" + "oo"];
static ["f" + "oo"] = 1;
get;
set;
static;
static = 1;
async;
foo; bar;
foo = 0; bar = 1;
}
class A1 {
static
a
static
}
class A2 {
get
*a(){}
}
class A3 {
static
*a(){}
}
class A4 {
async
a(){}
}
class A5 {
static
async
a
}
class A6 {
get
['a'](){}
}
class A7 {
static
get
static
(){}
}

View File

@ -3,6 +3,7 @@ class Foo {
foo = 1;
"foo";
"foo" = 1;
foo = super.foo();
["foo"];
["foo"] = 1;
["f" + "oo"];
@ -12,8 +13,49 @@ class Foo {
static foo = 1;
static "foo";
static "foo" = 1;
static foo = super.foo();
static ["foo"];
static ["foo"] = 1;
static ["f" + "oo"];
static ["f" + "oo"] = 1;
get;
set;
static;
static = 1;
async;
foo;bar;
foo = 0;bar = 1;
}
class A1 {
static a;
static;
}
class A2 {
get;
*a() {}
}
class A3 {
static *a() {}
}
class A4 {
async;
a() {}
}
class A5 {
static async;
a;
}
class A6 {
get ['a']() {}
}
class A7 {
static get static() {}
}

View File

@ -10,4 +10,46 @@ class Foo {
static ["foo"]() {}
static get foo() {}
static set foo(bar) {}
static static() {}
get
() {}
set
() {}
static
() {}
async
() {}
static
get
() {}
static
set
() {}
static
static
() {}
static
async
() {}
static
a
() {}
get
async
() {}
static
get
static
() {}
}

View File

@ -10,4 +10,27 @@ class Foo {
static ["foo"]() {}
static get foo() {}
static set foo(bar) {}
static static() {}
get() {}
set() {}
static() {}
async() {}
static get() {}
static set() {}
static static() {}
static async() {}
static a() {}
get async() {}
static get static() {}
}

View File

@ -29,3 +29,17 @@ class Foo {
@bar
set bar(foo) {}
}
@foo
export default class Foo {
bar() {
class Baz {}
}
}
@foo
export class Foo {
bar() {
class Baz {}
}
}

View File

@ -29,3 +29,17 @@ class Foo {
@bar
set bar(foo) {}
}
@foo
export default class Foo {
bar() {
class Baz {}
}
}
@foo
export class Foo {
bar() {
class Baz {}
}
}

View File

@ -0,0 +1 @@
export async function foo() {}

View File

@ -0,0 +1 @@
export async function foo() {}

View File

@ -0,0 +1 @@
export default async () => await foo()

View File

@ -0,0 +1 @@
export default (async () => await foo());

View File

@ -0,0 +1 @@
export default async function bar() {}

View File

@ -0,0 +1 @@
export default async function bar() {}

View File

@ -0,0 +1 @@
export * as default from "foo";

View File

@ -0,0 +1 @@
export * as default from "foo";

View File

@ -10,3 +10,4 @@ false;
0b10;
0o70;
0X1F;
-0b1111011;

View File

@ -10,3 +10,4 @@ false;
0b10;
0o70;
0X1F;
-0b1111011;

View File

@ -0,0 +1,3 @@
var { ...{ z } } = { z: 1 };
var { ...{ x = 5 } } = { x : 1 };
({ x, ...{ y, z } } = o);

View File

@ -0,0 +1,3 @@
var { ...{ z } } = { z: 1 };
var { ...{ x = 5 } } = { x: 1 };
({ x, ...{ y, z } } = o);

View File

@ -0,0 +1,9 @@
class A {
foo() {
return "bar";
}
}
class B extends A {
foo = super.foo();
}

View File

@ -0,0 +1,30 @@
var A = function () {
function A() {
babelHelpers.classCallCheck(this, A);
}
babelHelpers.createClass(A, [{
key: "foo",
value: function foo() {
return "bar";
}
}]);
return A;
}();
var B = function (_A) {
babelHelpers.inherits(B, _A);
function B(...args) {
var _temp, _this, _ret;
babelHelpers.classCallCheck(this, B);
return _ret = (_temp = (_this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this, ...args)), _this), Object.defineProperty(_this, "foo", {
enumerable: true,
writable: true,
value: babelHelpers.get(B.prototype.__proto__ || Object.getPrototypeOf(B.prototype), "foo", _this).call(_this)
}), _temp), babelHelpers.possibleConstructorReturn(_this, _ret);
}
return B;
}(A);

View File

@ -0,0 +1,14 @@
const calls = [];
function foo(target) {
calls.push(target.name);
}
@foo
export default class Foo {
bar() {
class Baz {}
}
}
assert.deepEqual(calls, ["Foo"]);

View File

@ -2,4 +2,6 @@ var z = {};
var { ...x } = z;
var { x, ...y } = z;
var { [x]: x, ...y } = z;
(function({ x, ...y }) { })
(function({ x, ...y }) { });
({ x, ...{ y, z } } = o);

View File

@ -1,11 +1,23 @@
var z = {};
var x = babelHelpers.objectWithoutProperties(z, []);
var x = z.x,
y = babelHelpers.objectWithoutProperties(z, ["x"]);
var x = z[x],
y = babelHelpers.objectWithoutProperties(z, [x]);
var _z = z,
x = babelHelpers.objectWithoutProperties(_z, []);
var _z2 = z,
x = _z2.x,
y = babelHelpers.objectWithoutProperties(_z2, ["x"]);
var _z3 = z,
x = _z3[x],
y = babelHelpers.objectWithoutProperties(_z3, [x]);
(function (_ref) {
var x = _ref.x,
y = babelHelpers.objectWithoutProperties(_ref, ["x"]);
});
var _o = o;
x = _o.x;
var _babelHelpers$objectW = babelHelpers.objectWithoutProperties(_o, ["x"]);
y = _babelHelpers$objectW.y;
z = _babelHelpers$objectW.z;
_o;

View File

@ -0,0 +1 @@
export * as default from "foo";

View File

@ -0,0 +1,2 @@
import * as _default from "foo";
export { _default as default };

View File

@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-export-extensions"]
}

View File

@ -17,3 +17,6 @@ let {
} = complex;
let { x4: { ...y4 } } = z;
var { ...{ z } } = { z: 1 };
var { ...{ x = 5 } } = { x : 1 };

View File

@ -24,3 +24,6 @@ let {
let {} = z,
y4 = babelHelpers.objectWithoutProperties(z.x4, []);
var { z } = babelHelpers.objectWithoutProperties({ z: 1 }, []);
var { x = 5 } = babelHelpers.objectWithoutProperties({ x: 1 }, []);

View File

@ -8,7 +8,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-template",
"main": "lib/index.js",
"dependencies": {
"babylon": "7.0.0-beta.8",
"babylon": "7.0.0-beta.10",
"babel-traverse": "7.0.0-alpha.9",
"babel-types": "7.0.0-alpha.9",
"lodash": "^4.2.0"

View File

@ -12,7 +12,7 @@
"babel-helper-function-name": "7.0.0-alpha.7",
"babel-messages": "7.0.0-alpha.9",
"babel-types": "7.0.0-alpha.9",
"babylon": "7.0.0-beta.8",
"babylon": "7.0.0-beta.10",
"debug": "^2.2.0",
"globals": "^9.0.0",
"invariant": "^2.2.0",