Add support for declare module.exports (#72)

* Add support for declare module.exports

* Use doublequotes

* Use expect instead of eat
This commit is contained in:
Daniel Tschinder
2016-07-28 22:16:58 +02:00
committed by GitHub
parent fd18d89d8e
commit f576865ce9
5 changed files with 214 additions and 1 deletions

View File

@@ -66,7 +66,11 @@ pp.flowParseDeclare = function (node) {
} else if (this.match(tt._var)) {
return this.flowParseDeclareVariable(node);
} else if (this.isContextual("module")) {
return this.flowParseDeclareModule(node);
if (this.lookahead().type === tt.dot) {
return this.flowParseDeclareModuleExports(node);
} else {
return this.flowParseDeclareModule(node);
}
} else if (this.isContextual("type")) {
return this.flowParseDeclareTypeAlias(node);
} else if (this.isContextual("interface")) {
@@ -109,6 +113,14 @@ pp.flowParseDeclareModule = function (node) {
return this.finishNode(node, "DeclareModule");
};
pp.flowParseDeclareModuleExports = function (node) {
this.expectContextual("module");
this.expect(tt.dot);
this.expectContextual("exports");
node.typeAnnotation = this.flowParseTypeAnnotation();
return this.finishNode(node, "DeclareModuleExports");
};
pp.flowParseDeclareTypeAlias = function (node) {
this.next();
this.flowParseTypeAlias(node);