Fix crash when exporting type of existing variable

Summary:
When using flow syntax like this, the parser would throw an error.

```
const foo = new ClassInstance();
export type {foo};
```

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D39850098

fbshipit-source-id: 28a7748892559c2c4a0fb8afa8612cbeb5568058
This commit is contained in:
Pieter De Baets
2022-10-03 04:15:04 -07:00
committed by Facebook GitHub Bot
parent b9e9e852a6
commit b9a03ce197
+3 -2
View File
@@ -26,8 +26,9 @@ function getTypes(ast: $FlowFixMe): TypeDeclarationMap {
return ast.body.reduce((types, node) => {
if (node.type === 'ExportNamedDeclaration' && node.exportKind === 'type') {
if (
node.declaration.type === 'TypeAlias' ||
node.declaration.type === 'InterfaceDeclaration'
node.declaration != null &&
(node.declaration.type === 'TypeAlias' ||
node.declaration.type === 'InterfaceDeclaration')
) {
types[node.declaration.id.name] = node.declaration;
}