Merge branch 'master' into 7.0
This commit is contained in:
commit
5e0cce4974
158
CHANGELOG.md
158
CHANGELOG.md
@ -15,6 +15,164 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
|
||||
|
||||
See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) for the pre-6.8.0 version Changelog.
|
||||
|
||||
## 6.16.0 (2017-02-23)
|
||||
|
||||
### :rocket: New Feature
|
||||
|
||||
***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder)
|
||||
|
||||
We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/)
|
||||
|
||||
We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc.
|
||||
|
||||
To enable `estree` mode simply add the plugin in the config:
|
||||
```json
|
||||
{
|
||||
"plugins": [ "estree" ]
|
||||
}
|
||||
```
|
||||
|
||||
If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned.
|
||||
|
||||
Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew)
|
||||
|
||||
Babylon exports a new function to parse a single expression
|
||||
|
||||
```js
|
||||
import { parseExpression } from 'babylon';
|
||||
|
||||
const ast = parseExpression('x || y && z', options);
|
||||
```
|
||||
|
||||
The returned AST will only consist of the expression. The options are the same as for `parse()`
|
||||
|
||||
Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
|
||||
|
||||
A new option was added to babylon allowing to change the intial linenumber for the first line which is usually `1`.
|
||||
Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
|
||||
|
||||
Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
|
||||
|
||||
Added support for function predicates which flow introduced in version 0.33.0
|
||||
|
||||
```js
|
||||
declare function is_number(x: mixed): boolean %checks(typeof x === "number");
|
||||
```
|
||||
|
||||
Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder)
|
||||
|
||||
Added support for imports within module declarations which flow introduced in version 0.37.0
|
||||
|
||||
```js
|
||||
declare module "C" {
|
||||
import type { DT } from "D";
|
||||
declare export type CT = { D: DT };
|
||||
}
|
||||
```
|
||||
|
||||
### :eyeglasses: Spec Compliancy
|
||||
|
||||
Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
|
||||
|
||||
This example now correctly throws an error when there is a semicolon after the decorator:
|
||||
|
||||
```js
|
||||
class A {
|
||||
@a;
|
||||
foo(){}
|
||||
}
|
||||
```
|
||||
|
||||
Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder)
|
||||
|
||||
Using keywords in imports is not allowed anymore:
|
||||
|
||||
```js
|
||||
import { default } from "foo";
|
||||
import { a as debugger } from "foo";
|
||||
```
|
||||
|
||||
Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
|
||||
|
||||
In flow it is now forbidden to overwrite the primitve types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
|
||||
|
||||
Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
|
||||
|
||||
The following code now correctly throws an error
|
||||
|
||||
```js
|
||||
import type { type a } from "foo";
|
||||
```
|
||||
|
||||
Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine)
|
||||
|
||||
Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour.
|
||||
|
||||
If you enable the flow plugin you can only define the type of the class properties, but not initialize them.
|
||||
|
||||
Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder)
|
||||
|
||||
Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`.
|
||||
|
||||
```js
|
||||
export default async function bar() {};
|
||||
```
|
||||
|
||||
### :nail_care: Polish
|
||||
|
||||
Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng)
|
||||
|
||||
### :bug: Bug Fix
|
||||
|
||||
Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder)
|
||||
|
||||
Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng)
|
||||
|
||||
ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder)
|
||||
|
||||
Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder)
|
||||
|
||||
Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder)
|
||||
|
||||
Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder)
|
||||
|
||||
Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng)
|
||||
|
||||
Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper)
|
||||
|
||||
|
||||
### :house: Internal
|
||||
|
||||
Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray)
|
||||
|
||||
Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray)
|
||||
|
||||
Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder)
|
||||
|
||||
chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot])
|
||||
|
||||
Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder)
|
||||
|
||||
Update eslint-config-babel to the latest version 🚀 ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot])
|
||||
|
||||
Update eslint-config-babel to the latest version 🚀 ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot])
|
||||
|
||||
devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo)
|
||||
|
||||
Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder)
|
||||
|
||||
Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder)
|
||||
|
||||
### :memo: Documentation
|
||||
|
||||
Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng)
|
||||
|
||||
Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu)
|
||||
|
||||
Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro)
|
||||
|
||||
AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens)
|
||||
|
||||
## 6.15.0 (2017-01-10)
|
||||
|
||||
### :eyeglasses: Spec Compliancy
|
||||
|
||||
@ -61,6 +61,8 @@ mind. When in doubt, use `.parse()`.
|
||||
Babylon generates AST according to [Babel AST format][].
|
||||
It is based on [ESTree spec][] with the following deviations:
|
||||
|
||||
> There is now an `estree` plugin which reverts these deviations
|
||||
|
||||
- [Literal][] token is replaced with [StringLiteral][], [NumericLiteral][], [BooleanLiteral][], [NullLiteral][], [RegExpLiteral][]
|
||||
- [Property][] token is replaced with [ObjectProperty][] and [ObjectMethod][]
|
||||
- [MethodDefinition][] is replaced with [ClassMethod][]
|
||||
@ -117,6 +119,7 @@ require("babylon").parse("code", {
|
||||
|
||||
### Plugins
|
||||
|
||||
- `estree`
|
||||
- `jsx`
|
||||
- `flow`
|
||||
- `doExpressions`
|
||||
|
||||
@ -1139,7 +1139,7 @@ interface ExportNamedDeclaration <: ModuleDeclaration {
|
||||
}
|
||||
```
|
||||
|
||||
An export named declaration, e.g., `export {foo, bar};`, `export {foo} from "mod";` or `export var foo = 1;`.
|
||||
An export named declaration, e.g., `export {foo, bar};`, `export {foo} from "mod";`, `export var foo = 1;` or `export * as foo from "bar";`.
|
||||
|
||||
_Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state._
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
"eslint": "^3.7.1",
|
||||
"eslint-config-babel": "^6.0.0",
|
||||
"eslint-plugin-flowtype": "^2.20.0",
|
||||
"flow-bin": "^0.38.0",
|
||||
"flow-bin": "^0.40.0",
|
||||
"nyc": "^10.0.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"rollup": "^0.41.0",
|
||||
|
||||
@ -61,7 +61,7 @@ pp.getExpression = function() {
|
||||
// the AST node that the inner parser gave them in another node.
|
||||
|
||||
// Parse a full expression. The optional arguments are used to
|
||||
// forbid the `in` operator (in for loops initalization expressions)
|
||||
// forbid the `in` operator (in for loops initialization expressions)
|
||||
// and provide reference for storing '=' operator inside shorthand
|
||||
// property assignment in contexts where both object expression
|
||||
// and object pattern might appear (so it's possible to raise
|
||||
@ -595,7 +595,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
|
||||
const spreadNodeStartPos = this.state.start;
|
||||
const spreadNodeStartLoc = this.state.startLoc;
|
||||
spreadStart = this.state.start;
|
||||
exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStartLoc, spreadNodeStartPos));
|
||||
exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStartPos, spreadNodeStartLoc));
|
||||
break;
|
||||
} else {
|
||||
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos));
|
||||
@ -1093,7 +1093,11 @@ pp.parseAwait = function (node) {
|
||||
pp.parseYield = function () {
|
||||
const node = this.startNode();
|
||||
this.next();
|
||||
if (this.match(tt.semi) || this.canInsertSemicolon() || (!this.match(tt.star) && !this.state.type.startsExpr)) {
|
||||
if (
|
||||
this.match(tt.semi) ||
|
||||
this.canInsertSemicolon() ||
|
||||
(!this.match(tt.star) && !this.state.type.startsExpr)
|
||||
) {
|
||||
node.delegate = false;
|
||||
node.argument = null;
|
||||
} else {
|
||||
|
||||
@ -76,7 +76,6 @@ pp.parseStatement = function (declaration, topLevel) {
|
||||
|
||||
case tt._class:
|
||||
if (!declaration) this.unexpected();
|
||||
this.takeDecorators(node);
|
||||
return this.parseClass(node, true);
|
||||
|
||||
case tt._if: return this.parseIfStatement(node);
|
||||
@ -617,6 +616,7 @@ pp.parseFunctionParams = function (node) {
|
||||
|
||||
pp.parseClass = function (node, isStatement, optionalId) {
|
||||
this.next();
|
||||
this.takeDecorators(node);
|
||||
this.parseClassId(node, isStatement, optionalId);
|
||||
this.parseClassSuper(node);
|
||||
this.parseClassBody(node);
|
||||
@ -646,6 +646,9 @@ pp.parseClassBody = function (node) {
|
||||
|
||||
while (!this.eat(tt.braceR)) {
|
||||
if (this.eat(tt.semi)) {
|
||||
if (decorators.length > 0) {
|
||||
this.raise(this.state.lastTokEnd, "Decorators must not be followed by a semicolon");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -748,13 +751,8 @@ pp.parseClassBody = function (node) {
|
||||
};
|
||||
|
||||
pp.parseClassProperty = function (node) {
|
||||
const noPluginMsg = "You can only use Class Properties when the 'classProperties' plugin is enabled.";
|
||||
if (!node.typeAnnotation && !this.hasPlugin("classProperties")) {
|
||||
this.raise(node.start, noPluginMsg);
|
||||
}
|
||||
|
||||
if (this.match(tt.eq)) {
|
||||
if (!this.hasPlugin("classProperties")) this.raise(this.state.start, noPluginMsg);
|
||||
if (!this.hasPlugin("classProperties")) this.unexpected();
|
||||
this.next();
|
||||
node.value = this.parseMaybeAssign();
|
||||
} else {
|
||||
@ -822,8 +820,6 @@ pp.parseExport = function (node) {
|
||||
let needsSemi = false;
|
||||
if (this.eat(tt._function)) {
|
||||
expr = this.parseFunction(expr, true, false, false, true);
|
||||
} else if (this.eatContextual("async") && this.eat(tt._function)) {
|
||||
expr = this.parseFunction(expr, true, false, true, true);
|
||||
} else if (this.match(tt._class)) {
|
||||
expr = this.parseClass(expr, true, true);
|
||||
} else {
|
||||
|
||||
@ -944,14 +944,14 @@ export default function (instance) {
|
||||
});
|
||||
|
||||
instance.extend("parseParenItem", function (inner) {
|
||||
return function (node, startLoc, startPos) {
|
||||
node = inner.call(this, node, startLoc, startPos);
|
||||
return function (node, startPos, startLoc) {
|
||||
node = inner.call(this, node, startPos, startLoc);
|
||||
if (this.eat(tt.question)) {
|
||||
node.optional = true;
|
||||
}
|
||||
|
||||
if (this.match(tt.colon)) {
|
||||
const typeCastNode = this.startNodeAt(startLoc, startPos);
|
||||
const typeCastNode = this.startNodeAt(startPos, startLoc);
|
||||
typeCastNode.expression = node;
|
||||
typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ export const keywords = {
|
||||
"class": new KeywordTokenType("class"),
|
||||
"extends": new KeywordTokenType("extends", { beforeExpr }),
|
||||
"export": new KeywordTokenType("export"),
|
||||
"import": new KeywordTokenType("import"),
|
||||
"import": new KeywordTokenType("import", { startsExpr }),
|
||||
"yield": new KeywordTokenType("yield", { beforeExpr, startsExpr }),
|
||||
"null": new KeywordTokenType("null", { startsExpr }),
|
||||
"true": new KeywordTokenType("true", { startsExpr }),
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
export async function foo() {}
|
||||
export default async function bar() {}
|
||||
@ -1,172 +0,0 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"specifiers": [],
|
||||
"source": null,
|
||||
"declaration": {
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 7,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 22,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"expression": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 28,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 28
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExportDefaultDeclaration",
|
||||
"start": 31,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"declaration": {
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 46,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 61,
|
||||
"end": 64,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"generator": false,
|
||||
"expression": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 67,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 36
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
(function*() {
|
||||
{ *[yield iter]() {} }
|
||||
return { *[yield iter]() {} }
|
||||
})
|
||||
|
||||
197
test/fixtures/esprima/es2015-generator/generator-method-with-computed-name/expected.json
vendored
Normal file
197
test/fixtures/esprima/es2015-generator/generator-method-with-computed-name/expected.json
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "FunctionExpression",
|
||||
"start": 1,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 13,
|
||||
"end": 50,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ReturnStatement",
|
||||
"start": 19,
|
||||
"end": 48,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 26,
|
||||
"end": 48,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectMethod",
|
||||
"start": 28,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"method": true,
|
||||
"shorthand": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "YieldExpression",
|
||||
"start": 30,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start": 36,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "iter"
|
||||
},
|
||||
"name": "iter"
|
||||
}
|
||||
},
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 44,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:6)"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
class Foo {
|
||||
bar: string = 'bizz';
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["flow"],
|
||||
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:14)"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
class Foo {
|
||||
bar = 'bizz';
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
class Foo {
|
||||
bar;
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||
}
|
||||
7
test/fixtures/experimental/decorators/export-default-with-nested-class/actual.js
vendored
Normal file
7
test/fixtures/experimental/decorators/export-default-with-nested-class/actual.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
@ParentDecorator
|
||||
export default class ParentClass {
|
||||
makeNestedClass() {
|
||||
class NestedClass {
|
||||
}
|
||||
}
|
||||
}
|
||||
240
test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json
vendored
Normal file
240
test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 109,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 109,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExportDefaultDeclaration",
|
||||
"start": 17,
|
||||
"end": 109,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"declaration": {
|
||||
"type": "ClassDeclaration",
|
||||
"start": 32,
|
||||
"end": 109,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 38,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "ParentClass"
|
||||
},
|
||||
"name": "ParentClass"
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 0,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"identifierName": "ParentDecorator"
|
||||
},
|
||||
"name": "ParentDecorator"
|
||||
}
|
||||
}
|
||||
],
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 50,
|
||||
"end": 109,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 54,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 54,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "makeNestedClass"
|
||||
},
|
||||
"name": "makeNestedClass"
|
||||
},
|
||||
"static": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 72,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 78,
|
||||
"end": 103,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 84,
|
||||
"end": 95,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "NestedClass"
|
||||
},
|
||||
"name": "NestedClass"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 96,
|
||||
"end": 103,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
4
test/fixtures/experimental/decorators/no-semi/actual.js
vendored
Normal file
4
test/fixtures/experimental/decorators/no-semi/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
@a;
|
||||
m(){}
|
||||
}
|
||||
3
test/fixtures/experimental/decorators/no-semi/options.json
vendored
Normal file
3
test/fixtures/experimental/decorators/no-semi/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Decorators must not be followed by a semicolon (2:5)"
|
||||
}
|
||||
3
test/fixtures/experimental/dynamic-import/generator/actual.js
vendored
Normal file
3
test/fixtures/experimental/dynamic-import/generator/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function* a() {
|
||||
yield import('http');
|
||||
}
|
||||
171
test/fixtures/experimental/dynamic-import/generator/expected.json
vendored
Normal file
171
test/fixtures/experimental/dynamic-import/generator/expected.json
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"generator": true,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 14,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 18,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "YieldExpression",
|
||||
"start": 18,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": {
|
||||
"type": "CallExpression",
|
||||
"start": 24,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Import",
|
||||
"start": 24,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"start": 31,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "http",
|
||||
"raw": "'http'"
|
||||
},
|
||||
"value": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
4
test/fixtures/flow/comment/spread/actual.js
vendored
Normal file
4
test/fixtures/flow/comment/spread/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/* hi */
|
||||
function commentsAttachedToIdentifier() {
|
||||
var x = (...args: any) => {};
|
||||
}
|
||||
275
test/fixtures/flow/comment/spread/expected.json
vendored
Normal file
275
test/fixtures/flow/comment/spread/expected.json
vendored
Normal file
@ -0,0 +1,275 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 84,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 84,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 9,
|
||||
"end": 84,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 18,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 37
|
||||
},
|
||||
"identifierName": "commentsAttachedToIdentifier"
|
||||
},
|
||||
"name": "commentsAttachedToIdentifier",
|
||||
"leadingComments": null
|
||||
},
|
||||
"generator": false,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 49,
|
||||
"end": 84,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 40
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 53,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 57,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 57,
|
||||
"end": 58,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start": 61,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"expression": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start": 62,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start": 65,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "args"
|
||||
},
|
||||
"name": "args"
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 69,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start": 71,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 79,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 28
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " hi ",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
"value": " hi ",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -7,10 +7,10 @@ class A<T = string> {}
|
||||
class A<T: ?string = string> {}
|
||||
class A<S, T: ?string = string> {}
|
||||
class A<S = number, T: ?string = string> {}
|
||||
(class A<T = string> {})
|
||||
(class A<T: ?string = string> {})
|
||||
(class A<S, T: ?string = string> {})
|
||||
(class A<S = number, T: ?string = string> {})
|
||||
;(class A<T = string> {})
|
||||
;(class A<T: ?string = string> {})
|
||||
;(class A<S, T: ?string = string> {})
|
||||
;(class A<S = number, T: ?string = string> {})
|
||||
declare class A<T = string> {}
|
||||
declare class A<T: ?string = string> {}
|
||||
declare class A<S, T: ?string = string> {}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user