Gabe Levi fe5193a40a Support defaults in Flow's type parameter declarations
The primary goal of this commit is to add the ability to parse type parameter
declarations with defaults, like `type Foo<T = string> = T`. While I was in the
code, I fixed a few small things, like

* Type parameter declarations need 1 or more type parameters.
* The existential type `*` is not a valid type parameter.
* The existential type `*` is a primary type
* The param list for type parameter declarations now consists of
  `TypeParameter` nodes
2016-04-27 16:12:10 -04:00

283 lines
6.3 KiB
JSON

{
"type": "File",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareInterface",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"name": "I"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 35
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 22,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 33
}
},
"key": {
"type": "Identifier",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 25
}
},
"name": "foo"
},
"value": {
"type": "StringTypeAnnotation",
"start": 27,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 33
}
}
},
"optional": false
}
],
"indexers": []
}
},
{
"type": "DeclareInterface",
"start": 36,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 54,
"end": 55,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 19
}
},
"name": "I"
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 55,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 22
}
},
"params": [
{
"type": "TypeParameter",
"start": 56,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 21
}
},
"name": "T"
}
]
},
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 59,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 33
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 61,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 31
}
},
"key": {
"type": "Identifier",
"start": 61,
"end": 64,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 28
}
},
"name": "foo"
},
"value": {
"type": "GenericTypeAnnotation",
"start": 66,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 30
},
"end": {
"line": 2,
"column": 31
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 66,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 30
},
"end": {
"line": 2,
"column": 31
}
},
"name": "T"
}
},
"optional": false
}
],
"indexers": []
}
}
],
"directives": []
}
}