aws-sdk-flow-decl-gen
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -7,2 +7,6 @@ 'use strict'; | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
@@ -215,3 +219,23 @@ | ||
}); | ||
return _astTypes.builders.intersectionTypeAnnotation([commonPart, _astTypes.builders.unionTypeAnnotation(discriminatedParts)]); | ||
return flattenIntersection(_astTypes.builders.intersectionTypeAnnotation([commonPart, _astTypes.builders.unionTypeAnnotation(discriminatedParts)])); | ||
} | ||
function flattenIntersection(intersectionType) { | ||
(0, _invariant2.default)(intersectionType.type === 'IntersectionTypeAnnotation', 'Not an intersection type'); | ||
(0, _invariant2.default)(intersectionType.types.length === 2, 'Expected an intersection of two types'); | ||
(0, _invariant2.default)(intersectionType.types[0].type === 'ObjectTypeAnnotation', 'First type should be the common part, an object type'); | ||
(0, _invariant2.default)(intersectionType.types[1].type === 'UnionTypeAnnotation', 'Second type should be a union'); | ||
(0, _invariant2.default)(intersectionType.types[1].types.every(memberType => memberType.type === 'ObjectTypeAnnotation'), 'Second type must be a union of object types'); | ||
var _intersectionType$typ = (0, _slicedToArray3.default)(intersectionType.types, 2); | ||
const commonPart = _intersectionType$typ[0]; | ||
const discriminatedParts = _intersectionType$typ[1].types; | ||
return _astTypes.builders.unionTypeAnnotation(discriminatedParts.map(part => ({ | ||
type: 'ObjectTypeAnnotation', | ||
properties: [].concat((0, _toConsumableArray3.default)(commonPart.properties), (0, _toConsumableArray3.default)(part.properties)), | ||
indexers: [].concat((0, _toConsumableArray3.default)(commonPart.indexers), (0, _toConsumableArray3.default)(part.indexers)), | ||
callProperties: [].concat((0, _toConsumableArray3.default)(commonPart.callProperties), (0, _toConsumableArray3.default)(part.callProperties)) | ||
}))); | ||
} |
{ | ||
"name": "aws-sdk-flow-decl-gen", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Generate Flow declaration types from the AWS SDK for JavaScript", | ||
@@ -58,2 +58,3 @@ "main": "dist/index.js", | ||
"chai": "^3.5.0", | ||
"chai-deep-match": "^1.0.2", | ||
"child-process-promise": "^2.0.3", | ||
@@ -78,3 +79,3 @@ "compat": "^1.0.3", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"npm-run-all": "^2.3.0", | ||
"npm-run-all": "^3.0.0", | ||
"nyc": "^8.1.0", | ||
@@ -81,0 +82,0 @@ "semantic-release": "^4.3.5", |
45171
605
34