Skip to content

Commit

Permalink
Add EmptyTypeAnnotation
Browse files Browse the repository at this point in the history
Added to Flow in facebook/flow#c603505583993aa953904005f91c350f4b65d6bd
Parser support added in babel/babylon#171.
  • Loading branch information
samwgoldman committed Oct 13, 2016
1 parent 71790aa commit 39cdd97
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/babel-generator/src/generators/flow.js
Expand Up @@ -167,6 +167,10 @@ export function MixedTypeAnnotation() {
this.word("mixed");
}

export function EmptyTypeAnnotation() {
this.word("empty");
}

export function NullableTypeAnnotation(node: Object) {
this.token("?");
this.print(node.typeAnnotation, node);
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-traverse/src/path/inference/index.js
Expand Up @@ -73,6 +73,8 @@ function _isBaseType(baseName: string, type?, soft?): boolean {
return t.isAnyTypeAnnotation(type);
} else if (baseName === "mixed") {
return t.isMixedTypeAnnotation(type);
} else if (baseName === "empty") {
return t.isEmptyTypeAnnotation(type);
} else if (baseName === "void") {
return t.isVoidTypeAnnotation(type);
} else {
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-types/README.md
Expand Up @@ -755,6 +755,11 @@ See also `t.isMixedTypeAnnotation(node, opts)` and `t.assertMixedTypeAnnotation(

Aliases: `Flow`, `FlowBaseAnnotation`

### t.emptyTypeAnnotation()

See also `t.isEmptyTypeAnnotation(node, opts)` and `t.assertEmptyTypeAnnotation(node, opts)`.

Aliases: `Flow`, `FlowBaseAnnotation`

### t.newExpression(callee, arguments)

Expand Down
4 changes: 4 additions & 0 deletions packages/babel-types/src/definitions/flow.js
Expand Up @@ -167,6 +167,10 @@ defineType("MixedTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});

defineType("EmptyTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});

defineType("NullableTypeAnnotation", {
visitor: ["typeAnnotation"],
aliases: ["Flow"],
Expand Down

0 comments on commit 39cdd97

Please sign in to comment.