Merge pull request #5317 from babel/update-babylon

Update to babylon@7.0.0-beta.0
This commit is contained in:
Henry Zhu
2017-02-18 13:06:39 -05:00
committed by GitHub
15 changed files with 41 additions and 78 deletions

View File

@@ -581,8 +581,8 @@ declare class BabelNodeDeclareVariable extends BabelNode {
id: any;
}
declare class BabelNodeExistentialTypeParam extends BabelNode {
type: "ExistentialTypeParam";
declare class BabelNodeExistsTypeAnnotation extends BabelNode {
type: "ExistsTypeAnnotation";
}
declare class BabelNodeFunctionTypeAnnotation extends BabelNode {
@@ -632,8 +632,8 @@ declare class BabelNodeNullableTypeAnnotation extends BabelNode {
typeAnnotation: any;
}
declare class BabelNodeNumericLiteralTypeAnnotation extends BabelNode {
type: "NumericLiteralTypeAnnotation";
declare class BabelNodeNumberLiteralTypeAnnotation extends BabelNode {
type: "NumberLiteralTypeAnnotation";
}
declare class BabelNodeNumberTypeAnnotation extends BabelNode {
@@ -873,7 +873,7 @@ type BabelNodeClass = BabelNodeClassDeclaration | BabelNodeClassExpression;
type BabelNodeModuleDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration;
type BabelNodeExportDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration;
type BabelNodeModuleSpecifier = BabelNodeExportSpecifier | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeExportDefaultSpecifier | BabelNodeExportNamespaceSpecifier;
type BabelNodeFlow = BabelNodeAnyTypeAnnotation | BabelNodeArrayTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeBooleanLiteralTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeClassImplements | BabelNodeClassProperty | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareVariable | BabelNodeExistentialTypeParam | BabelNodeFunctionTypeAnnotation | BabelNodeFunctionTypeParam | BabelNodeGenericTypeAnnotation | BabelNodeInterfaceExtends | BabelNodeInterfaceDeclaration | BabelNodeIntersectionTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeNullableTypeAnnotation | BabelNodeNumericLiteralTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeStringLiteralTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeTupleTypeAnnotation | BabelNodeTypeofTypeAnnotation | BabelNodeTypeAlias | BabelNodeTypeAnnotation | BabelNodeTypeCastExpression | BabelNodeTypeParameterDeclaration | BabelNodeTypeParameterInstantiation | BabelNodeObjectTypeAnnotation | BabelNodeObjectTypeCallProperty | BabelNodeObjectTypeIndexer | BabelNodeObjectTypeProperty | BabelNodeQualifiedTypeIdentifier | BabelNodeUnionTypeAnnotation | BabelNodeVoidTypeAnnotation;
type BabelNodeFlow = BabelNodeAnyTypeAnnotation | BabelNodeArrayTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeBooleanLiteralTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeClassImplements | BabelNodeClassProperty | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareVariable | BabelNodeExistsTypeAnnotation | BabelNodeFunctionTypeAnnotation | BabelNodeFunctionTypeParam | BabelNodeGenericTypeAnnotation | BabelNodeInterfaceExtends | BabelNodeInterfaceDeclaration | BabelNodeIntersectionTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeNullableTypeAnnotation | BabelNodeNumberLiteralTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeStringLiteralTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeTupleTypeAnnotation | BabelNodeTypeofTypeAnnotation | BabelNodeTypeAlias | BabelNodeTypeAnnotation | BabelNodeTypeCastExpression | BabelNodeTypeParameterDeclaration | BabelNodeTypeParameterInstantiation | BabelNodeObjectTypeAnnotation | BabelNodeObjectTypeCallProperty | BabelNodeObjectTypeIndexer | BabelNodeObjectTypeProperty | BabelNodeQualifiedTypeIdentifier | BabelNodeUnionTypeAnnotation | BabelNodeVoidTypeAnnotation;
type BabelNodeFlowBaseAnnotation = BabelNodeAnyTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeVoidTypeAnnotation;
type BabelNodeFlowDeclaration = BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareVariable | BabelNodeInterfaceDeclaration | BabelNodeTypeAlias;
type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText;
@@ -965,7 +965,7 @@ declare module "babel-types" {
declare function declareModuleExports(typeAnnotation: any): BabelNodeDeclareModuleExports;
declare function declareTypeAlias(id: any, typeParameters: any, right: any): BabelNodeDeclareTypeAlias;
declare function declareVariable(id: any): BabelNodeDeclareVariable;
declare function existentialTypeParam(): BabelNodeExistentialTypeParam;
declare function existsTypeAnnotation(): BabelNodeExistsTypeAnnotation;
declare function functionTypeAnnotation(typeParameters: any, params: any, rest: any, returnType: any): BabelNodeFunctionTypeAnnotation;
declare function functionTypeParam(name: any, typeAnnotation: any): BabelNodeFunctionTypeParam;
declare function genericTypeAnnotation(id: any, typeParameters: any): BabelNodeGenericTypeAnnotation;
@@ -974,7 +974,7 @@ declare module "babel-types" {
declare function intersectionTypeAnnotation(types: any): BabelNodeIntersectionTypeAnnotation;
declare function mixedTypeAnnotation(): BabelNodeMixedTypeAnnotation;
declare function nullableTypeAnnotation(typeAnnotation: any): BabelNodeNullableTypeAnnotation;
declare function numericLiteralTypeAnnotation(): BabelNodeNumericLiteralTypeAnnotation;
declare function numberLiteralTypeAnnotation(): BabelNodeNumberLiteralTypeAnnotation;
declare function numberTypeAnnotation(): BabelNodeNumberTypeAnnotation;
declare function stringLiteralTypeAnnotation(): BabelNodeStringLiteralTypeAnnotation;
declare function stringTypeAnnotation(): BabelNodeStringTypeAnnotation;
@@ -1101,7 +1101,7 @@ declare module "babel-types" {
declare function isDeclareModuleExports(node: Object, opts?: Object): boolean;
declare function isDeclareTypeAlias(node: Object, opts?: Object): boolean;
declare function isDeclareVariable(node: Object, opts?: Object): boolean;
declare function isExistentialTypeParam(node: Object, opts?: Object): boolean;
declare function isExistsTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isFunctionTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isFunctionTypeParam(node: Object, opts?: Object): boolean;
declare function isGenericTypeAnnotation(node: Object, opts?: Object): boolean;
@@ -1110,7 +1110,7 @@ declare module "babel-types" {
declare function isIntersectionTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isMixedTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isNullableTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isNumericLiteralTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isNumberLiteralTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isNumberTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isStringLiteralTypeAnnotation(node: Object, opts?: Object): boolean;
declare function isStringTypeAnnotation(node: Object, opts?: Object): boolean;

View File

@@ -34,7 +34,7 @@
"babel-register": "^6.23.0",
"babel-traverse": "^6.23.1",
"babel-types": "^6.23.0",
"babylon": "^6.11.0",
"babylon": "7.0.0-beta.0",
"convert-source-map": "^1.1.0",
"debug": "^2.1.1",
"json5": "^0.5.0",

View File

@@ -21,6 +21,6 @@
},
"devDependencies": {
"babel-helper-fixtures": "^6.22.0",
"babylon": "^6.11.0"
"babylon": "7.0.0-beta.0"
}
}

View File

@@ -79,7 +79,7 @@ export function DeclareVariable(node: Object) {
this.semicolon();
}
export function ExistentialTypeParam() {
export function ExistsTypeAnnotation() {
this.token("*");
}
@@ -146,10 +146,12 @@ export function _interfaceish(node: Object) {
}
export function _variance(node) {
if (node.variance === "plus") {
this.token("+");
} else if (node.variance === "minus") {
this.token("-");
if (node.variance) {
if (node.variance.kind === "plus") {
this.token("+");
} else if (node.variance.kind === "minus") {
this.token("-");
}
}
}
@@ -183,7 +185,7 @@ export function NullableTypeAnnotation(node: Object) {
}
export {
NumericLiteral as NumericLiteralTypeAnnotation,
NumericLiteral as NumberLiteralTypeAnnotation,
StringLiteral as StringLiteralTypeAnnotation,
} from "./types";

View File

@@ -84,10 +84,9 @@ const buildForXStatement = function (op) {
return function (node: Object) {
this.word("for");
this.space();
if (op === "await") {
if (op === "of" && node.await) {
this.word("await");
this.space();
op = "of";
}
this.token("(");
@@ -103,7 +102,6 @@ const buildForXStatement = function (op) {
export const ForInStatement = buildForXStatement("in");
export const ForOfStatement = buildForXStatement("of");
export const ForAwaitStatement = buildForXStatement("await");
export function DoWhileStatement(node: Object) {
this.word("do");

View File

@@ -2,18 +2,6 @@ import * as t from "babel-types";
import jsesc from "jsesc";
export function Identifier(node: Object) {
// FIXME: We hang variance off Identifer to support Flow's def-site variance.
// This is a terrible hack, but changing type annotations to use a new,
// dedicated node would be a breaking change. This should be cleaned up in
// the next major.
if (node.variance) {
if (node.variance === "plus") {
this.token("+");
} else if (node.variance === "minus") {
this.token("-");
}
}
this.word(node.name);
}

View File

@@ -41,8 +41,9 @@ const awaitVisitor = {
}
},
ForAwaitStatement(path, { file, wrapAwait }) {
ForOfStatement(path, { file, wrapAwait }) {
const { node } = path;
if (!node.await) return;
const build = rewriteForAwait(path, {
getAsyncIterator: file.addHelper("asyncIterator"),

View File

@@ -18,11 +18,11 @@ async function a() {
for ({ a } in {}) {}
for ({ a } of []) {}
async function a() {
for ({ a } of []) {}
for await ({ a } of []) {}
}
for (a in {}) {}
for (a of []) {}
async function a() {
for (a of []) {}
for await (a of []) {}
}

View File

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

View File

@@ -11,7 +11,7 @@
"babel-code-frame": "^6.22.0",
"babel-messages": "^6.23.0",
"babel-types": "^6.23.0",
"babylon": "^6.15.0",
"babylon": "7.0.0-beta.0",
"debug": "^2.2.0",
"globals": "^9.0.0",
"invariant": "^2.2.0",

View File

@@ -575,12 +575,12 @@ Aliases: `Flow`, `FlowBaseAnnotation`
---
### existentialTypeParam
### existsTypeAnnotation
```javascript
t.existentialTypeParam()
t.existsTypeAnnotation()
```
See also `t.isExistentialTypeParam(node, opts)` and `t.assertExistentialTypeParam(node, opts)`.
See also `t.isExistsTypeAnnotation(node, opts)` and `t.assertExistsTypeAnnotation(node, opts)`.
Aliases: `Flow`
@@ -694,21 +694,6 @@ See also `t.isFile(node, opts)` and `t.assertFile(node, opts)`.
---
### forAwaitStatement
```javascript
t.forAwaitStatement(left, right, body)
```
See also `t.isForAwaitStatement(node, opts)` and `t.assertForAwaitStatement(node, opts)`.
Aliases: `Scopable`, `Statement`, `For`, `BlockParent`, `Loop`, `ForXStatement`
- `left`: `VariableDeclaration | LVal` (required)
- `right`: `Expression` (required)
- `body`: `Statement` (required)
---
### forInStatement
```javascript
t.forInStatement(left, right, body)
@@ -726,7 +711,7 @@ Aliases: `Scopable`, `Statement`, `For`, `BlockParent`, `Loop`, `ForXStatement`
### forOfStatement
```javascript
t.forOfStatement(left, right, body)
t.forOfStatement(left, right, body, await)
```
See also `t.isForOfStatement(node, opts)` and `t.assertForOfStatement(node, opts)`.
@@ -736,6 +721,7 @@ Aliases: `Scopable`, `Statement`, `For`, `BlockParent`, `Loop`, `ForXStatement`
- `left`: `VariableDeclaration | LVal` (required)
- `right`: `Expression` (required)
- `body`: `Statement` (required)
- `await`: `boolean` (default: `false`)
---
@@ -1296,12 +1282,12 @@ Aliases: `Expression`, `Pureish`, `Literal`, `Immutable`
---
### numericLiteralTypeAnnotation
### numberLiteralTypeAnnotation
```javascript
t.numericLiteralTypeAnnotation()
t.numberLiteralTypeAnnotation()
```
See also `t.isNumericLiteralTypeAnnotation(node, opts)` and `t.assertNumericLiteralTypeAnnotation(node, opts)`.
See also `t.isNumberLiteralTypeAnnotation(node, opts)` and `t.assertNumberLiteralTypeAnnotation(node, opts)`.
Aliases: `Flow`

View File

@@ -13,6 +13,6 @@
"to-fast-properties": "^1.0.1"
},
"devDependencies": {
"babylon": "^6.8.2"
"babylon": "7.0.0-beta.0"
}
}

View File

@@ -178,6 +178,10 @@ defineType("ForOfStatement", {
},
body: {
validate: assertNodeType("Statement")
},
await: {
default: false,
validate: assertValueType("boolean")
}
}
});

View File

@@ -11,22 +11,6 @@ defineType("AwaitExpression", {
}
});
defineType("ForAwaitStatement", {
visitor: ["left", "right", "body"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
fields: {
left: {
validate: assertNodeType("VariableDeclaration", "LVal")
},
right: {
validate: assertNodeType("Expression")
},
body: {
validate: assertNodeType("Statement")
}
}
});
defineType("BindExpression", {
visitor: ["object", "callee"],
aliases: ["Expression"],

View File

@@ -111,7 +111,7 @@ defineType("DeclareVariable", {
}
});
defineType("ExistentialTypeParam", {
defineType("ExistsTypeAnnotation", {
aliases: ["Flow"]
});
@@ -179,7 +179,7 @@ defineType("NullableTypeAnnotation", {
}
});
defineType("NumericLiteralTypeAnnotation", {
defineType("NumberLiteralTypeAnnotation", {
aliases: ["Flow"],
fields: {
// todo