Add export interface Flow syntax support

An interface export is just like a type export. In fact, it's a syntax affordance which makes the following equivalent:

```javascript
interface I_ { ... }
export type I = I_;
```

```javascript
export interface I { ... }
```

See facebook/flow#1145
This commit is contained in:
Sam Goldman
2016-01-05 15:56:04 -08:00
parent 06545e6f70
commit 17d19a0056
8 changed files with 370 additions and 2 deletions

View File

@@ -687,7 +687,9 @@ export default function (instance) {
// export type
instance.extend("shouldParseExportDeclaration", function (inner) {
return function () {
return this.isContextual("type") || inner.call(this);
return this.isContextual("type")
|| this.isContextual("interface")
|| inner.call(this);
};
});
@@ -745,6 +747,11 @@ export default function (instance) {
// export type Foo = Bar;
return this.flowParseTypeAlias(declarationNode);
}
} else if (this.isContextual("interface")) {
node.exportKind = "type";
let declarationNode = this.startNode();
this.next();
return this.flowParseInterface(declarationNode);
} else {
return inner.call(this, node);
}