{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = removeTypeDuplicates;\n\nvar _generated = require(\"../../validators/generated\");\n\nfunction removeTypeDuplicates(nodes) {\n var generics = {};\n var bases = {};\n var typeGroups = [];\n var types = [];\n\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n if (!node) continue;\n\n if (types.indexOf(node) >= 0) {\n continue;\n }\n\n if ((0, _generated.isAnyTypeAnnotation)(node)) {\n return [node];\n }\n\n if ((0, _generated.isFlowBaseAnnotation)(node)) {\n bases[node.type] = node;\n continue;\n }\n\n if ((0, _generated.isUnionTypeAnnotation)(node)) {\n if (typeGroups.indexOf(node.types) < 0) {\n nodes = nodes.concat(node.types);\n typeGroups.push(node.types);\n }\n\n continue;\n }\n\n if ((0, _generated.isGenericTypeAnnotation)(node)) {\n var name = node.id.name;\n\n if (generics[name]) {\n var existing = generics[name];\n\n if (existing.typeParameters) {\n if (node.typeParameters) {\n existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));\n }\n } else {\n existing = node.typeParameters;\n }\n } else {\n generics[name] = node;\n }\n\n continue;\n }\n\n types.push(node);\n }\n\n for (var _i = 0, _Object$keys = Object.keys(bases); _i < _Object$keys.length; _i++) {\n var type = _Object$keys[_i];\n types.push(bases[type]);\n }\n\n for (var _i2 = 0, _Object$keys2 = Object.keys(generics); _i2 < _Object$keys2.length; _i2++) {\n var _name = _Object$keys2[_i2];\n types.push(generics[_name]);\n }\n\n return types;\n}","map":null,"metadata":{},"sourceType":"script"}