Sha256: 46a8bd291198550897e806cedc75045372e2712ecd578853d95a3bd159676327

Contents?: true

Size: 1.59 KB

Versions: 161

Compression:

Stored size: 1.59 KB

Contents

{"version":3,"names":["_index","require","_removeTypeDuplicates","_index2","createTSUnionType","typeAnnotations","types","map","type","isTSTypeAnnotation","typeAnnotation","flattened","removeTypeDuplicates","length","tsUnionType"],"sources":["../../../src/builders/typescript/createTSUnionType.ts"],"sourcesContent":["import { tsUnionType } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/typescript/removeTypeDuplicates.ts\";\nimport { isTSTypeAnnotation } from \"../../validators/generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createTSUnionType(\n  typeAnnotations: Array<t.TSTypeAnnotation | t.TSType>,\n): t.TSType {\n  const types = typeAnnotations.map(type => {\n    return isTSTypeAnnotation(type) ? type.typeAnnotation : type;\n  });\n  const flattened = removeTypeDuplicates(types);\n\n  if (flattened.length === 1) {\n    return flattened[0];\n  } else {\n    return tsUnionType(flattened);\n  }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAOe,SAASG,iBAAiBA,CACvCC,eAAqD,EAC3C;EACV,MAAMC,KAAK,GAAGD,eAAe,CAACE,GAAG,CAACC,IAAI,IAAI;IACxC,OAAO,IAAAC,0BAAkB,EAACD,IAAI,CAAC,GAAGA,IAAI,CAACE,cAAc,GAAGF,IAAI;EAC9D,CAAC,CAAC;EACF,MAAMG,SAAS,GAAG,IAAAC,6BAAoB,EAACN,KAAK,CAAC;EAE7C,IAAIK,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,kBAAW,EAACH,SAAS,CAAC;EAC/B;AACF","ignoreList":[]}

Version data entries

161 entries across 15 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.49 node_modules/@babel/helper-builder-binary-assignment-operator-visitor/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/node_modules/@babel/traverse/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-async-generator-functions/node_modules/@babel/traverse/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helpers/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-split-export-declaration/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-wrap-function/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-environment-visitor/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-classes/node_modules/@babel/helper-replace-supers/node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-remap-async-to-generator/node_modules/@babel/traverse/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-simple-access/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/preset-modules/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-classes/node_modules/@babel/traverse/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/traverse/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-function-name/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-module-imports/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map
immosquare-cleaner-0.1.49 node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map