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])));
108
0
23
+ 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; }
7
237
2
+ 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)]), ), ), ); }
2
14
2
+ 23 other calls in file
GitHub: openapi/preset-effector
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))), ]), ); }
2
14
2
+ 5 other calls in file
GitHub: johanholmerin/tscm
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'),
0
31
2
+ 11 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)