Add EmptyTypeAnnotation (#4724)

Added to Flow in facebook/flow#c603505583993aa953904005f91c350f4b65d6bd
Parser support added in babel/babylon#171.
This commit is contained in:
Sam Goldman 2016-10-14 12:16:02 -07:00 committed by Henry Zhu
parent 50baac3251
commit 15183078e6
4 changed files with 15 additions and 0 deletions

View File

@ -167,6 +167,10 @@ export function MixedTypeAnnotation() {
this.word("mixed"); this.word("mixed");
} }
export function EmptyTypeAnnotation() {
this.word("empty");
}
export function NullableTypeAnnotation(node: Object) { export function NullableTypeAnnotation(node: Object) {
this.token("?"); this.token("?");
this.print(node.typeAnnotation, node); this.print(node.typeAnnotation, node);

View File

@ -73,6 +73,8 @@ function _isBaseType(baseName: string, type?, soft?): boolean {
return t.isAnyTypeAnnotation(type); return t.isAnyTypeAnnotation(type);
} else if (baseName === "mixed") { } else if (baseName === "mixed") {
return t.isMixedTypeAnnotation(type); return t.isMixedTypeAnnotation(type);
} else if (baseName === "empty") {
return t.isEmptyTypeAnnotation(type);
} else if (baseName === "void") { } else if (baseName === "void") {
return t.isVoidTypeAnnotation(type); return t.isVoidTypeAnnotation(type);
} else { } else {

View File

@ -755,6 +755,11 @@ See also `t.isMixedTypeAnnotation(node, opts)` and `t.assertMixedTypeAnnotation(
Aliases: `Flow`, `FlowBaseAnnotation` Aliases: `Flow`, `FlowBaseAnnotation`
### t.emptyTypeAnnotation()
See also `t.isEmptyTypeAnnotation(node, opts)` and `t.assertEmptyTypeAnnotation(node, opts)`.
Aliases: `Flow`, `FlowBaseAnnotation`
### t.newExpression(callee, arguments) ### t.newExpression(callee, arguments)

View File

@ -167,6 +167,10 @@ defineType("MixedTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"] aliases: ["Flow", "FlowBaseAnnotation"]
}); });
defineType("EmptyTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
defineType("NullableTypeAnnotation", { defineType("NullableTypeAnnotation", {
visitor: ["typeAnnotation"], visitor: ["typeAnnotation"],
aliases: ["Flow"], aliases: ["Flow"],