Merge branch 'master' into 7.0

# Conflicts:
#	src/parser/index.js
This commit is contained in:
Daniel Tschinder
2017-02-12 13:32:06 +01:00
80 changed files with 5370 additions and 53 deletions

View File

@@ -0,0 +1,2 @@
call(1);
run(2);

View File

@@ -0,0 +1,459 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 4,
"column": 7
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 4,
"column": 7
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 8
}
},
"expression": {
"type": "CallExpression",
"start": 0,
"end": 7,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 7
}
},
"callee": {
"type": "Identifier",
"start": 0,
"end": 4,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "call"
},
"name": "call"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 6
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
]
}
},
{
"type": "ExpressionStatement",
"start": 9,
"end": 16,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 7
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 6
}
},
"callee": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 3
},
"identifierName": "run"
},
"name": "run"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
]
}
}
],
"directives": []
},
"comments": [],
"tokens": [
{
"type": {
"label": "name",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"value": "call",
"start": 0,
"end": 4,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 4
}
}
},
{
"type": {
"label": "(",
"beforeExpr": true,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 5
}
}
},
{
"type": {
"label": "num",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": 1,
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 6
}
}
},
{
"type": {
"label": ")",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
}
}
},
{
"type": {
"label": ";",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 7,
"end": 8,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
}
},
{
"type": {
"label": "name",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"value": "run",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 3
}
}
},
{
"type": {
"label": "(",
"beforeExpr": true,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 12,
"end": 13,
"loc": {
"start": {
"line": 4,
"column": 3
},
"end": {
"line": 4,
"column": 4
}
}
},
{
"type": {
"label": "num",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": 2,
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
}
}
},
{
"type": {
"label": ")",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 6
}
}
},
{
"type": {
"label": ";",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 7
}
}
},
{
"type": {
"label": "eof",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 16,
"end": 16,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 7
}
}
}
]
}

View File

@@ -0,0 +1,3 @@
{
"startLine": 3
}

View File

@@ -0,0 +1 @@
import { default } from "foo";

View File

@@ -0,0 +1,4 @@
{
"plugins": ["flow"],
"throws": "default is a reserved word (1:9)"
}

View File

@@ -0,0 +1 @@
import { typeof } from "foo";

View File

@@ -0,0 +1,4 @@
{
"plugins": ["flow"],
"throws": "typeof is a reserved word (1:9)"
}

View File

@@ -0,0 +1 @@
import { typeof } from "foo";

View File

@@ -0,0 +1,3 @@
{
"throws": "typeof is a reserved word (1:9)"
}

View File

@@ -0,0 +1 @@
import { debugger } from "foo";

View File

@@ -0,0 +1,3 @@
{
"throws": "debugger is a reserved word (1:9)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:26)"
}
"throws": "yield is a reserved word (1:26)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:25)"
}
"throws": "yield is a reserved word (1:25)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:46)"
}
"throws": "yield is a reserved word (1:46)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:29)"
"throws": "yield is a reserved word (1:29)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:28)"
}
"throws": "yield is a reserved word (1:28)"
}

View File

@@ -0,0 +1,3 @@
class A {
foo() {}
}

View File

@@ -0,0 +1,154 @@
{
"type": "File",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "MethodDefinition",
"start": 12,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 10
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "method",
"value": {
"type": "FunctionExpression",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 10
}
},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 10
}
},
"body": []
},
"expression": false
}
}
]
}
}
]
}
}

View File

@@ -0,0 +1,5 @@
function foo() {
"use strict";
var a = 1;
"use strict";
}

View File

@@ -0,0 +1,218 @@
{
"type": "File",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 5,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 15
}
},
"expression": {
"type": "Literal",
"start": 19,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"value": "use strict",
"raw": "\"use strict\""
},
"directive": "use strict"
},
{
"type": "VariableDeclaration",
"start": 35,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 12
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 39,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
}
},
"value": 1,
"raw": "1"
}
}
],
"kind": "var"
},
{
"type": "ExpressionStatement",
"start": 48,
"end": 61,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 15
}
},
"expression": {
"type": "Literal",
"start": 48,
"end": 60,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 14
}
},
"value": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}

View File

@@ -0,0 +1,4 @@
function foo () {
"use smth"
1+1;
}

View File

@@ -0,0 +1,184 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 16,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 12
}
},
"expression": {
"type": "Literal",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 12
}
},
"value": "use smth",
"raw": "\"use smth\""
},
"directive": "use smth"
},
{
"type": "ExpressionStatement",
"start": 33,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 6
}
},
"expression": {
"type": "BinaryExpression",
"start": 33,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 5
}
},
"left": {
"type": "Literal",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 3
}
},
"value": 1,
"raw": "1"
},
"operator": "+",
"right": {
"type": "Literal",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 5
}
},
"value": 1,
"raw": "1"
}
}
}
]
}
}
]
}
}

View File

@@ -0,0 +1,3 @@
"use strict";
var a = 1;
"use strict";

View File

@@ -0,0 +1,165 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "Literal",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"value": "use strict",
"raw": "\"use strict\""
},
"directive": "use strict"
},
{
"type": "VariableDeclaration",
"start": 14,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 18,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 9
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 9
}
},
"value": 1,
"raw": "1"
}
}
],
"kind": "var"
},
{
"type": "ExpressionStatement",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"expression": {
"type": "Literal",
"start": 25,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 12
}
},
"value": "use strict",
"raw": "\"use strict\""
}
}
]
}
}

View File

@@ -0,0 +1 @@
"use\x20strict";

View File

@@ -0,0 +1,66 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"expression": {
"type": "Literal",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"value": "use\\x20strict",
"raw": "\"use\\x20strict\""
},
"directive": "use\\x20strict"
}
]
}
}

View File

@@ -0,0 +1,2 @@
var a = true;
var b = false;

View File

@@ -0,0 +1,167 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 8,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 12
}
},
"value": true,
"raw": "true"
}
}
],
"kind": "var"
},
{
"type": "VariableDeclaration",
"start": 14,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 13
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "b"
},
"name": "b"
},
"init": {
"type": "Literal",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 13
}
},
"value": false,
"raw": "false"
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1 @@
var a = null;

View File

@@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 8,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 12
}
},
"value": null,
"raw": "null"
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1 @@
var a = 1;

View File

@@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 10
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 10
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 8,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
},
"value": 1,
"raw": "1"
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1 @@
var a = /.*/i;

View File

@@ -0,0 +1,104 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 13
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"value": "/.*/i",
"raw": "/.*/i",
"regex": {
"pattern": ".*",
"flags": "i"
}
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1 @@
var a = "string";

View File

@@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "Literal",
"start": 8,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 16
}
},
"value": "string",
"raw": "\"string\""
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1,3 @@
var bar = {
foo() {}
};

View File

@@ -0,0 +1,172 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "bar"
},
"name": "bar"
},
"init": {
"type": "ObjectExpression",
"start": 10,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 3,
"column": 1
}
},
"properties": [
{
"type": "Property",
"start": 14,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 10
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "foo"
},
"name": "foo"
},
"kind": "init",
"value": {
"type": "FunctionExpression",
"start": 17,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 10
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 10
}
},
"body": []
}
}
}
]
}
}
],
"kind": "var"
}
]
}
}

View File

@@ -0,0 +1 @@
const a = { foo: 1 };

View File

@@ -0,0 +1,153 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "ObjectExpression",
"start": 10,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 20
}
},
"properties": [
{
"type": "Property",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "foo"
},
"name": "foo"
},
"value": {
"type": "Literal",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
}
},
"value": 1,
"raw": "1"
},
"kind": "init"
}
]
}
}
],
"kind": "const"
}
]
}
}

3
test/fixtures/estree/options.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"plugins": ["flow", "jsx", "estree"]
}

View File

@@ -0,0 +1 @@
var {...{z}} = { z: 1};

View File

@@ -0,0 +1,243 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 22
}
},
"id": {
"type": "ObjectPattern",
"start": 4,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 12
}
},
"properties": [
{
"type": "RestProperty",
"start": 5,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 11
}
},
"argument": {
"type": "ObjectPattern",
"start": 8,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 11
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "z"
},
"name": "z"
},
"value": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "z"
},
"name": "z"
},
"extra": {
"shorthand": true
}
}
]
}
}
]
},
"init": {
"type": "ObjectExpression",
"start": 15,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 22
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 17,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 21
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "z"
},
"name": "z"
},
"value": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
]
}
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
var { ...{ x = 5 } } = {x : 1};

View File

@@ -0,0 +1,278 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 30
}
},
"id": {
"type": "ObjectPattern",
"start": 4,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 20
}
},
"properties": [
{
"type": "RestProperty",
"start": 6,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 18
}
},
"argument": {
"type": "ObjectPattern",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 11,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 16
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
},
"name": "x"
},
"value": {
"type": "AssignmentPattern",
"start": 11,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 16
}
},
"left": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
}
},
"extra": {
"rawValue": 5,
"raw": "5"
},
"value": 5
}
},
"extra": {
"shorthand": true
}
}
]
}
}
]
},
"init": {
"type": "ObjectExpression",
"start": 23,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 30
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 29
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "x"
},
"name": "x"
},
"value": {
"type": "NumericLiteral",
"start": 28,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 29
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
]
}
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
declare function foo(x: mixed): boolean %checks(x !== null);

View File

@@ -0,0 +1,226 @@
{
"type": "File",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 60
}
},
"program": {
"type": "Program",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 60
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareFunction",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 60
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 59
},
"identifierName": "foo"
},
"name": "foo",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 20,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 59
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 20,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 59
}
},
"typeParameters": null,
"params": [
{
"type": "FunctionTypeParam",
"start": 21,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 29
}
},
"name": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 22
},
"identifierName": "x"
},
"name": "x"
},
"optional": false,
"typeAnnotation": {
"type": "MixedTypeAnnotation",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 29
}
}
}
}
],
"rest": null,
"returnType": {
"type": "BooleanTypeAnnotation",
"start": 32,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 39
}
}
}
},
"predicate": {
"type": "DeclaredPredicate",
"start": 40,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 40
},
"end": {
"line": 1,
"column": 59
}
},
"expression": {
"type": "BinaryExpression",
"start": 48,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 58
}
},
"left": {
"type": "Identifier",
"start": 48,
"end": 49,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 49
},
"identifierName": "x"
},
"name": "x"
},
"operator": "!==",
"right": {
"type": "NullLiteral",
"start": 54,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 54
},
"end": {
"line": 1,
"column": 58
}
}
}
}
}
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
var f = (x: mixed): %checks => typeof x === "string";

View File

@@ -0,0 +1,256 @@
{
"type": "File",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"program": {
"type": "Program",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"sourceType": "module",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 52
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "f"
},
"name": "f"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 8,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 52
}
},
"returnType": {
"type": "TypeAnnotation",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 27
}
},
"typeAnnotation": null,
"predicate": {
"type": "InferredPredicate",
"start": 20,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 27
}
}
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "x"
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 10,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 17
}
},
"typeAnnotation": {
"type": "MixedTypeAnnotation",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
}
}
}
}
}
],
"body": {
"type": "BinaryExpression",
"start": 31,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 52
}
},
"left": {
"type": "UnaryExpression",
"start": 31,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 39
}
},
"operator": "typeof",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 38,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 39
},
"identifierName": "x"
},
"name": "x"
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "===",
"right": {
"type": "StringLiteral",
"start": 44,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 44
},
"end": {
"line": 1,
"column": 52
}
},
"extra": {
"rawValue": "string",
"raw": "\"string\""
},
"value": "string"
}
}
}
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
function foo(x: mixed): %checks { return typeof x === "string"; };

View File

@@ -0,0 +1,270 @@
{
"type": "File",
"start": 0,
"end": 66,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 66
}
},
"program": {
"type": "Program",
"start": 0,
"end": 66,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 66
}
},
"sourceType": "module",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 65,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 65
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 13,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "x"
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 14,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 21
}
},
"typeAnnotation": {
"type": "MixedTypeAnnotation",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
}
}
}
}
],
"returnType": {
"type": "TypeAnnotation",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 31
}
},
"typeAnnotation": null,
"predicate": {
"type": "InferredPredicate",
"start": 24,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 31
}
}
}
},
"body": {
"type": "BlockStatement",
"start": 32,
"end": 65,
"loc": {
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 65
}
},
"body": [
{
"type": "ReturnStatement",
"start": 34,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 63
}
},
"argument": {
"type": "BinaryExpression",
"start": 41,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 41
},
"end": {
"line": 1,
"column": 62
}
},
"left": {
"type": "UnaryExpression",
"start": 41,
"end": 49,
"loc": {
"start": {
"line": 1,
"column": 41
},
"end": {
"line": 1,
"column": 49
}
},
"operator": "typeof",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 48,
"end": 49,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 49
},
"identifierName": "x"
},
"name": "x"
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "===",
"right": {
"type": "StringLiteral",
"start": 54,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 54
},
"end": {
"line": 1,
"column": 62
}
},
"extra": {
"rawValue": "string",
"raw": "\"string\""
},
"value": "string"
}
}
}
],
"directives": []
}
},
{
"type": "EmptyStatement",
"start": 65,
"end": 66,
"loc": {
"start": {
"line": 1,
"column": 65
},
"end": {
"line": 1,
"column": 66
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
var f = (x: mixed): % checks => typeof x === "string";

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected ; (1:18)"
}

View File

@@ -0,0 +1,3 @@
function foo(x): % checks {
return typeof x === "string";
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Spaces between ´%´ and ´checks´ are not allowed here. (1:17)"
}

View File

@@ -0,0 +1 @@
declare function my_filter<T, P: $Pred<1>>(v: Array<T>, cb: P): Array<$Refine<T,P,1>>;

View File

@@ -0,0 +1,599 @@
{
"type": "File",
"start": 0,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 86
}
},
"program": {
"type": "Program",
"start": 0,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 86
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareFunction",
"start": 0,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 86
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 85
},
"identifierName": "my_filter"
},
"name": "my_filter",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 26,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 85
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 26,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 85
}
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 26,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 42
}
},
"params": [
{
"type": "TypeParameter",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 28
}
},
"name": "T",
"variance": null
},
{
"type": "TypeParameter",
"start": 30,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 41
}
},
"name": "P",
"variance": null,
"bound": {
"type": "TypeAnnotation",
"start": 31,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 41
}
},
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 33,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 41
}
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 38,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 41
}
},
"params": [
{
"type": "NumericLiteralTypeAnnotation",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
}
},
"value": 1,
"extra": {
"rawValue": 1,
"raw": "1"
}
}
]
},
"id": {
"type": "Identifier",
"start": 33,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 38
},
"identifierName": "$Pred"
},
"name": "$Pred"
}
}
}
}
]
},
"params": [
{
"type": "FunctionTypeParam",
"start": 43,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 54
}
},
"name": {
"type": "Identifier",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 44
},
"identifierName": "v"
},
"name": "v"
},
"optional": false,
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 46,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 46
},
"end": {
"line": 1,
"column": 54
}
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 51,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 51
},
"end": {
"line": 1,
"column": 54
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 52,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 52
},
"end": {
"line": 1,
"column": 53
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 52,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 52
},
"end": {
"line": 1,
"column": 53
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"id": {
"type": "Identifier",
"start": 46,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 46
},
"end": {
"line": 1,
"column": 51
},
"identifierName": "Array"
},
"name": "Array"
}
}
},
{
"type": "FunctionTypeParam",
"start": 56,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 56
},
"end": {
"line": 1,
"column": 61
}
},
"name": {
"type": "Identifier",
"start": 56,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 56
},
"end": {
"line": 1,
"column": 58
},
"identifierName": "cb"
},
"name": "cb"
},
"optional": false,
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 60,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 60
},
"end": {
"line": 1,
"column": 61
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 60,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 60
},
"end": {
"line": 1,
"column": 61
},
"identifierName": "P"
},
"name": "P"
}
}
}
],
"rest": null,
"returnType": {
"type": "GenericTypeAnnotation",
"start": 64,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 64
},
"end": {
"line": 1,
"column": 85
}
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 69,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 69
},
"end": {
"line": 1,
"column": 85
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 70,
"end": 84,
"loc": {
"start": {
"line": 1,
"column": 70
},
"end": {
"line": 1,
"column": 84
}
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 77,
"end": 84,
"loc": {
"start": {
"line": 1,
"column": 77
},
"end": {
"line": 1,
"column": 84
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 78,
"end": 79,
"loc": {
"start": {
"line": 1,
"column": 78
},
"end": {
"line": 1,
"column": 79
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 78,
"end": 79,
"loc": {
"start": {
"line": 1,
"column": 78
},
"end": {
"line": 1,
"column": 79
},
"identifierName": "T"
},
"name": "T"
}
},
{
"type": "GenericTypeAnnotation",
"start": 80,
"end": 81,
"loc": {
"start": {
"line": 1,
"column": 80
},
"end": {
"line": 1,
"column": 81
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 80,
"end": 81,
"loc": {
"start": {
"line": 1,
"column": 80
},
"end": {
"line": 1,
"column": 81
},
"identifierName": "P"
},
"name": "P"
}
},
{
"type": "NumericLiteralTypeAnnotation",
"start": 82,
"end": 83,
"loc": {
"start": {
"line": 1,
"column": 82
},
"end": {
"line": 1,
"column": 83
}
},
"value": 1,
"extra": {
"rawValue": 1,
"raw": "1"
}
}
]
},
"id": {
"type": "Identifier",
"start": 70,
"end": 77,
"loc": {
"start": {
"line": 1,
"column": 70
},
"end": {
"line": 1,
"column": 77
},
"identifierName": "$Refine"
},
"name": "$Refine"
}
}
]
},
"id": {
"type": "Identifier",
"start": 64,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 64
},
"end": {
"line": 1,
"column": 69
},
"identifierName": "Array"
},
"name": "Array"
}
}
}
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
const fn: ( Object, Object Object ) => void = ( o1, o2, ) => o1;

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected , (1:27)"
}

View File

@@ -0,0 +1,2 @@
const fn: ( Object, ?Object ) => void = ( o1, o2 ) => o1;
const fn: ( Object, ?Object, ) => void = ( o1, o2, ) => o1;

View File

@@ -0,0 +1,618 @@
{
"type": "File",
"start": 0,
"end": 117,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 59
}
},
"program": {
"type": "Program",
"start": 0,
"end": 117,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 59
}
},
"sourceType": "module",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 57,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 57
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 37
},
"identifierName": "fn"
},
"name": "fn",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 8,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 37
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 10,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 37
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 12,
"end": 19,
"loc": {
"start": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
}
},
"end": {
"line": 1,
"column": 19
}
},
"name": null,
"optional": false,
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "Object"
},
"name": "Object"
}
}
},
{
"type": "FunctionTypeParam",
"start": 20,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 27
}
},
"name": null,
"optional": false,
"typeAnnotation": {
"type": "NullableTypeAnnotation",
"start": 20,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 27
}
},
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 21,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 27
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 21,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 27
},
"identifierName": "Object"
},
"name": "Object"
}
}
}
}
],
"rest": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 33,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 37
}
}
},
"typeParameters": null
}
}
},
"init": {
"type": "ArrowFunctionExpression",
"start": 40,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 40
},
"end": {
"line": 1,
"column": 56
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 42,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 42
},
"end": {
"line": 1,
"column": 44
},
"identifierName": "o1"
},
"name": "o1"
},
{
"type": "Identifier",
"start": 46,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 46
},
"end": {
"line": 1,
"column": 48
},
"identifierName": "o2"
},
"name": "o2"
}
],
"body": {
"type": "Identifier",
"start": 54,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 54
},
"end": {
"line": 1,
"column": 56
},
"identifierName": "o1"
},
"name": "o1"
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 58,
"end": 117,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 59
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 64,
"end": 116,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 58
}
},
"id": {
"type": "Identifier",
"start": 64,
"end": 96,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 38
},
"identifierName": "fn"
},
"name": "fn",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 66,
"end": 96,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 38
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 68,
"end": 96,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 38
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 70,
"end": 77,
"loc": {
"start": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 18
}
},
"end": {
"line": 2,
"column": 19
}
},
"name": null,
"optional": false,
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 70,
"end": 76,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 18
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 70,
"end": 76,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 18
},
"identifierName": "Object"
},
"name": "Object"
}
}
},
{
"type": "FunctionTypeParam",
"start": 78,
"end": 85,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 27
}
},
"name": null,
"optional": false,
"typeAnnotation": {
"type": "NullableTypeAnnotation",
"start": 78,
"end": 85,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 27
}
},
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 79,
"end": 85,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 27
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 79,
"end": 85,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 27
},
"identifierName": "Object"
},
"name": "Object"
}
}
}
}
],
"rest": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 92,
"end": 96,
"loc": {
"start": {
"line": 2,
"column": 34
},
"end": {
"line": 2,
"column": 38
}
}
},
"typeParameters": null
}
}
},
"init": {
"type": "ArrowFunctionExpression",
"start": 99,
"end": 116,
"loc": {
"start": {
"line": 2,
"column": 41
},
"end": {
"line": 2,
"column": 58
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 101,
"end": 103,
"loc": {
"start": {
"line": 2,
"column": 43
},
"end": {
"line": 2,
"column": 45
},
"identifierName": "o1"
},
"name": "o1"
},
{
"type": "Identifier",
"start": 105,
"end": 107,
"loc": {
"start": {
"line": 2,
"column": 47
},
"end": {
"line": 2,
"column": 49
},
"identifierName": "o2"
},
"name": "o2"
}
],
"body": {
"type": "Identifier",
"start": 114,
"end": 116,
"loc": {
"start": {
"line": 2,
"column": 56
},
"end": {
"line": 2,
"column": 58
},
"identifierName": "o1"
},
"name": "o1"
}
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
const fn = async (a?: any): Promise<void> => {};

View File

@@ -0,0 +1,249 @@
{
"type": "File",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 48
}
},
"program": {
"type": "Program",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 48
}
},
"sourceType": "module",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 48
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 47
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "fn"
},
"name": "fn"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 11,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 47
}
},
"returnType": {
"type": "TypeAnnotation",
"start": 26,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 41
}
},
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 28,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 41
}
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 35,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 41
}
},
"params": [
{
"type": "VoidTypeAnnotation",
"start": 36,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 40
}
}
}
]
},
"id": {
"type": "Identifier",
"start": 28,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 35
},
"identifierName": "Promise"
},
"name": "Promise"
}
}
},
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [
{
"type": "Identifier",
"start": 18,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "a"
},
"name": "a",
"optional": true,
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 20,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 25
}
},
"typeAnnotation": {
"type": "AnyTypeAnnotation",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 25
}
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 45,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 47
}
},
"body": [],
"directives": []
}
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
import { type as debugger } from "foo";

View File

@@ -0,0 +1,3 @@
{
"throws": "debugger is a reserved word (1:17)"
}

View File

@@ -0,0 +1 @@
import { type debugger } from "foo";

View File

@@ -0,0 +1,3 @@
{
"throws": "debugger is a reserved word (1:9)"
}

View File

@@ -1,4 +1,4 @@
{
"throws": "Unexpected token (1:14)",
"throws": "delete is a reserved word (1:14)",
"plugins": ["flow", "jsx"]
}