Skip to content

Commit

Permalink
fix(flow): declare interface identifier as lexcial binding
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 15, 2019
1 parent ee68d6d commit 72fe811
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-parser/src/plugins/flow.js
Expand Up @@ -461,6 +461,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
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();
Expand Down
@@ -0,0 +1,3 @@
interface Foo {}

export type { Foo }
@@ -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": []
}
}

0 comments on commit 72fe811

Please sign in to comment.