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

279 lines
6.5 KiB
JSON

{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "module",
"body": [
{
"type": "InterfaceDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
},
"name": "A"
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 11,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 14
}
},
"params": [
{
"type": "TypeParameter",
"start": 12,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
},
"name": "T"
}
]
},
"extends": [
{
"type": "InterfaceExtends",
"start": 23,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 27
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"name": "B"
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 24,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 27
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
},
"name": "T"
}
}
]
}
},
{
"type": "InterfaceExtends",
"start": 29,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
}
},
"name": "C"
},
"typeParameters": {
"type": "TypeParameterInstantiation",
"start": 30,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 33
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 32
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 32
}
},
"name": "T"
}
}
]
}
}
],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 34,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 36
}
},
"callProperties": [],
"properties": [],
"indexers": []
}
}
],
"directives": []
}
}