Add "mixed" Flow type

"mixed" is one of the base types listed here:

http://flowtype.org/docs/base-types.html

So this commit adds support for it.
This commit is contained in:
Greg Hurrell
2015-06-02 07:15:06 -07:00
parent d35be22f7d
commit 0c300058a3
5 changed files with 40 additions and 6 deletions

View File

@@ -415,6 +415,9 @@ pp.flow_identToTypeAnnotation = function (start, node, id) {
case "boolean":
return this.finishNode(node, "BooleanTypeAnnotation")
case "mixed":
return this.finishNode(node, "MixedTypeAnnotation")
case "number":
return this.finishNode(node, "NumberTypeAnnotation")

View File

@@ -103,6 +103,10 @@ export function IntersectionTypeAnnotation(node, print) {
print.join(node.types, { separator: " & " });
}
export function MixedTypeAnnotation() {
this.push("mixed");
}
export function NullableTypeAnnotation(node, print) {
this.push("?");
print.plain(node.typeAnnotation);

View File

@@ -93,6 +93,7 @@
"InterfaceExtends": ["Flow"],
"InterfaceDeclaration": ["Flow", "Statement", "Declaration"],
"IntersectionTypeAnnotation": ["Flow"],
"MixedTypeAnnotation": ["Flow"],
"NullableTypeAnnotation": ["Flow"],
"NumberTypeAnnotation": ["Flow"],
"StringLiteralTypeAnnotation": ["Flow"],

View File

@@ -91,6 +91,7 @@
"InterfaceExtends": ["id", "typeParameters"],
"InterfaceDeclaration": ["id", "typeParameters", "extends", "body"],
"IntersectionTypeAnnotation": ["types"],
"MixedTypeAnnotation": [],
"NullableTypeAnnotation": ["typeAnnotation"],
"NumberTypeAnnotation": [],
"StringLiteralTypeAnnotation": [],