From 698564efe4a16ed1018540e5a1ade23c5bc522e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 17 Sep 2021 11:24:47 -0400 Subject: [PATCH] review comments --- .../babel-parser/src/plugins/flow/index.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/babel-parser/src/plugins/flow/index.js b/packages/babel-parser/src/plugins/flow/index.js index aff52572a5e2..666a33c3a7fb 100644 --- a/packages/babel-parser/src/plugins/flow/index.js +++ b/packages/babel-parser/src/plugins/flow/index.js @@ -14,6 +14,7 @@ import { tokenLabelName, tt, type TokenType, + tokenIsFlowInterfaceOrTypeOrOpaque, } from "../../tokenizer/types"; import * as N from "../../types"; import type { Position } from "../../util/location"; @@ -1870,24 +1871,23 @@ export default (superClass: Class): Class => // export type shouldParseExportDeclaration(): boolean { - return ( - this.isContextual(tt._type) || - this.isContextual(tt._interface) || - this.isContextual(tt._opaque) || - (this.shouldParseEnums() && this.isContextual(tt._enum)) || - super.shouldParseExportDeclaration() - ); + const { type } = this.state; + if ( + tokenIsFlowInterfaceOrTypeOrOpaque(type) || + (this.shouldParseEnums() && type === tt._enum) + ) { + return !this.state.containsEsc; + } + return super.shouldParseExportDeclaration(); } isExportDefaultSpecifier(): boolean { + const { type } = this.state; if ( - tokenIsIdentifier(this.state.type) && - (this.state.value === "type" || - this.state.value === "interface" || - this.state.value === "opaque" || - (this.shouldParseEnums() && this.state.value === "enum")) + tokenIsFlowInterfaceOrTypeOrOpaque(type) || + (this.shouldParseEnums() && type === tt._enum) ) { - return false; + return this.state.containsEsc; } return super.isExportDefaultSpecifier();