Add support for flow's export type * from (#617)

This commit is contained in:
Nicolò Ribaudo
2017-07-12 05:56:04 +02:00
committed by Brian Ng
parent ff513df283
commit b0c3a9dcdd
10 changed files with 252 additions and 16 deletions

View File

@@ -1283,7 +1283,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
parseExport(node: N.ExportNamedDeclaration): N.ExportNamedDeclaration {
node = super.parseExport(node);
if (node.type === "ExportNamedDeclaration") {
if (
node.type === "ExportNamedDeclaration" ||
node.type === "ExportAllDeclaration"
) {
node.exportKind = node.exportKind || "value";
}
return node;
@@ -1315,6 +1318,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
}
shouldParseExportStar(): boolean {
return (
super.shouldParseExportStar() ||
(this.isContextual("type") && this.lookahead().type === tt.star)
);
}
parseExportStar(node: N.ExportNamedDeclaration, allowNamed: boolean): void {
if (this.eatContextual("type")) {
node.exportKind = "type";
allowNamed = false;
}
return super.parseExportStar(node, allowNamed);
}
parseClassId(node: N.Class, isStatement: boolean, optionalId: ?boolean) {
super.parseClassId(node, isStatement, optionalId);
if (this.isRelational("<")) {