How to use the tsTypeReference function from @babel/types

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

77
78
79
80
81
82
83
84
85
86
  if (!path.parent.typeParameters) {
    path.parent.typeParameters = t.tsTypeParameterInstantiation([]);
  }
  let param = path.parent.typeParameters.params.find(p => p.typeName.name === name[0]);
  if (!param) {
    path.parentPath.get('typeParameters').pushContainer('params', t.tsTypeReference(t.identifier(name[0])));
  }
}

// Keep going to all references of this reference.
fork icon108
star icon0
watch icon23

+ 13 other calls in file

69
70
71
72
73
74
75
76
77
78
}

function anyOf(variants) {
  return t.tsIntersectionType(
    variants.map((variant) =>
      t.tsTypeReference(
        t.identifier('Partial'),
        t.tsTypeParameterInstantiation([createInterface(variant)]),
      ),
    ),
fork icon2
star icon14
watch icon2

+ 23 other calls in file

20
21
22
23
24
25
26
27
28
29
}`,
  { allowAwaitOutsideFunction: true },
);

function contractGet({ contractName }) {
  return t.tsTypeReference(
    t.tsQualifiedName(t.identifier('typed'), t.identifier('Get')),
    t.tsTypeParameterInstantiation([
      t.tsTypeQuery(t.identifier(changeCase.camelCase(contractName))),
    ]),
fork icon2
star icon14
watch icon2

+ 11 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)