How to use the declareTypeAlias function from @babel/types

Find comprehensive JavaScript @babel/types.declareTypeAlias code examples handpicked from public code repositorys.

8
9
10
11
12
13
14
15
16
17
}

class FlowBuilder extends AbstractJsBuilder {
  buildUnion(object/*: Union*/) {
    const variants = object.variants.map((name) => bt.genericTypeAnnotation(bt.identifier(name)))
    const ast = bt.declareTypeAlias(
      bt.identifier(object.name),
      undefined,
      bt.unionTypeAnnotation(variants)
    )
fork icon9
star icon40
watch icon4

+ 35 other calls in file

67
68
69
70
71
72
73
74
75
76
  ]),
);
const stringableValue = t.genericTypeAnnotation(stringableId);

const validValueId = t.identifier('ValidValue');
const validValueType = t.declareTypeAlias(
  validValueId,
  null,
  t.unionTypeAnnotation([
    t.stringTypeAnnotation(),
fork icon1
star icon3
watch icon2

+ 30 other calls in file

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)