How to use the tsTypeParameterInstantiation function from @babel/types

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

73
74
75
76
77
78
79
80
81
82
// Replace the reference with the generic, or add a type parameter.
if (path.node.name === name) {
  path.replaceWith(t.identifier(name[0]));
} else {
  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])));
fork icon108
star icon0
watch icon23

+ 13 other calls in file

66
67
68
69
70
71
72
73
74
75
}

if (nullableType !== undefined && nullableType !== typeNode) {
	// Ideally we'd clone the `typeReference` path and add `typeParameters`.
	// But I don't know if there's an API or better pattern for it.
	typeReference.typeParameters = t.tsTypeParameterInstantiation([
		nullableType,
	]);
	changedSome = true;
}
fork icon7
star icon237
watch icon2

+ 220 other calls in file

71
72
73
74
75
76
77
78
79
80
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

22
23
24
25
26
27
28
29
30
31
);

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

+ 5 other calls in file

5
6
7
8
9
10
11
12
13
14
t.callExpression(
  t.memberExpression(t.identifier('Promise'), t.identifier('resolve')),
  [t.arrayExpression()]
),
{
  typeParameters: t.tsTypeParameterInstantiation([
    t.tsArrayType(
      t.tsTypeLiteral([
        t.tsPropertySignature(
          t.identifier('id'),
fork icon0
star icon31
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)