Debian Codegraph @

packages/babel-traverse/src/path/inference/util.ts

raw symbols SCIP
1 import {
2 createFlowUnionType,
3 createTSUnionType,
4 createUnionTypeAnnotation,
5 isFlowType,
6 isTSType,
7 } from "@babel/types";
8 import type * as t from "@babel/types";
9
10 export function createUnionType(
11 types: Array<t.FlowType | t.TSType>,
12 ): t.FlowType | t.TSType {
13 if (process.env.BABEL_8_BREAKING) {
14 if (isFlowType(types[0])) {
15 return createFlowUnionType(types as t.FlowType[]);
16 }
17 if (isTSType(types[0])) {
18 return createTSUnionType(types as t.TSType[]);
19 }
20 } else {
21 if (isFlowType(types[0])) {
22 if (createFlowUnionType) {
23 return createFlowUnionType(types as t.FlowType[]);
24 }
25
26 return createUnionTypeAnnotation(types as t.FlowType[]);
27 } else {
28 if (createTSUnionType) {
29 return createTSUnionType(types as t.TSType[]);
30 }
31 }
32 }
33 }