diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 024a21baa5ab..06c3d857c123 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -461,6 +461,7 @@ export default (superClass: Class): Class => isClass?: boolean = false, ): void { node.id = this.flowParseRestrictedIdentifier(/*liberal*/ !isClass); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-10044/input.js b/packages/babel-parser/test/fixtures/flow/regression/issue-10044/input.js new file mode 100644 index 000000000000..56b6af08ad4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-10044/input.js @@ -0,0 +1,3 @@ +interface Foo {} + +export type { Foo } diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-10044/output.json b/packages/babel-parser/test/fixtures/flow/regression/issue-10044/output.json new file mode 100644 index 000000000000..15c57d370772 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-10044/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "ExportNamedDeclaration", + "start": 18, + "end": 37, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "local": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "exported": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + } + ], + "source": null, + "exportKind": "type", + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file