mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Restructure getTypes function
Summary: There are two types of types we care about: - Type aliases - Interface Declarations These types can be exported. I think we should build the types dictionary from only those types. Everything else should be ignored. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D23120241 fbshipit-source-id: 9f023081d0f9c85b45407b180ae7c3e7391eb725
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5142e99437
commit
1435d654d7
+12
-3
@@ -20,10 +20,19 @@ const {buildComponentSchema} = require('./components/schema');
|
||||
const {processComponent} = require('./components');
|
||||
const {processModule} = require('./modules');
|
||||
|
||||
function getTypes(ast) {
|
||||
/**
|
||||
* This FlowFixMe is supposed to refer to an InterfaceDeclaration or TypeAlias
|
||||
* declaration type. Unfortunately, we don't have those types, because flow-parser
|
||||
* generates them, and flow-parser is not type-safe. In the future, we should find
|
||||
* a way to get these types from our flow parser library.
|
||||
*/
|
||||
function getTypes(ast): {[declarationName: string]: $FlowFixMe} {
|
||||
return ast.body.reduce((types, node) => {
|
||||
if (node.type === 'ExportNamedDeclaration') {
|
||||
if (node.declaration && node.declaration.type !== 'VariableDeclaration') {
|
||||
if (node.type === 'ExportNamedDeclaration' && node.exportKind === 'type') {
|
||||
if (
|
||||
node.declaration.type === 'TypeAlias' ||
|
||||
node.declaration.type === 'InterfaceDeclaration'
|
||||
) {
|
||||
types[node.declaration.id.name] = node.declaration;
|
||||
}
|
||||
} else if (
|
||||
|
||||
Reference in New Issue
Block a user