[Flow] Arrow function type parameter declarations

This commit is contained in:
Gabe Levi
2016-06-23 13:41:44 -07:00
parent cde17b33bd
commit 22374b6bec
12 changed files with 1192 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
{
"type": "File",
"start": 0,
"end": 0,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 0,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 0
}
},
"sourceType": "module",
"body": [],
"directives": []
}
}

View File

@@ -0,0 +1 @@
<T>"I'm not an arrow function"

View File

@@ -0,0 +1,4 @@
{
"plugins": ["flow", "jsx"],
"throws": "Unterminated JSX contents (1:3)"
}

View File

@@ -0,0 +1 @@
<T>"I'm not an arrow function"

View File

@@ -0,0 +1,4 @@
{
"plugins": ["flow"],
"throws": "Expected an arrow function after this type parameter declaration (1:0)"
}

View File

@@ -0,0 +1,5 @@
<T>() => 123;
<T>(x) => 123;
<T>(x: number) => 123;
<T>(x: number) => { 123 };

View File

@@ -0,0 +1,530 @@
{
"type": "File",
"start": 0,
"end": 78,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 78,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "NumericLiteral",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 14,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 17,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 13
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"name": "x"
}
],
"body": {
"type": "NumericLiteral",
"start": 24,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 13
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 29,
"end": 51,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 22
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 32,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 21
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 5
}
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 34,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 13
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 36,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
}
}
}
}
}
],
"body": {
"type": "NumericLiteral",
"start": 47,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 21
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 29,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 1
},
"end": {
"line": 3,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 52,
"end": 78,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 55,
"end": 77,
"loc": {
"start": {
"line": 4,
"column": 3
},
"end": {
"line": 4,
"column": 25
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 56,
"end": 57,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
}
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 57,
"end": 65,
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 13
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 59,
"end": 65,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
}
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 70,
"end": 77,
"loc": {
"start": {
"line": 4,
"column": 18
},
"end": {
"line": 4,
"column": 25
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 72,
"end": 75,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 23
}
},
"expression": {
"type": "NumericLiteral",
"start": 72,
"end": 75,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 23
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
],
"directives": []
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 52,
"end": 55,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 53,
"end": 54,
"loc": {
"start": {
"line": 4,
"column": 1
},
"end": {
"line": 4,
"column": 2
}
},
"name": "T"
}
]
}
}
}
],
"directives": []
}
}

View File

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

View File

@@ -0,0 +1,5 @@
<T>() => 123;
<T>(x) => 123;
<T>(x: number) => 123;
<T>(x: number) => { 123 };

View File

@@ -0,0 +1,530 @@
{
"type": "File",
"start": 0,
"end": 78,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 78,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 3,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 12
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "NumericLiteral",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 14,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 17,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 13
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"name": "x"
}
],
"body": {
"type": "NumericLiteral",
"start": 24,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 13
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 29,
"end": 51,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 22
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 32,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 21
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 5
}
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 34,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 13
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 36,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
}
}
}
}
}
],
"body": {
"type": "NumericLiteral",
"start": 47,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 21
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 29,
"end": 32,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 3,
"column": 1
},
"end": {
"line": 3,
"column": 2
}
},
"name": "T"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 52,
"end": 78,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 55,
"end": 77,
"loc": {
"start": {
"line": 4,
"column": 3
},
"end": {
"line": 4,
"column": 25
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 56,
"end": 57,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
}
},
"name": "x",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 57,
"end": 65,
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 13
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 59,
"end": 65,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
}
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 70,
"end": 77,
"loc": {
"start": {
"line": 4,
"column": 18
},
"end": {
"line": 4,
"column": 25
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 72,
"end": 75,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 23
}
},
"expression": {
"type": "NumericLiteral",
"start": 72,
"end": 75,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 23
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
],
"directives": []
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 52,
"end": 55,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 3
}
},
"params": [
{
"type": "TypeParameter",
"start": 53,
"end": 54,
"loc": {
"start": {
"line": 4,
"column": 1
},
"end": {
"line": 4,
"column": 2
}
},
"name": "T"
}
]
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,4 @@
{
"plugins": ["flow"]
}