MCPcopy Create free account
hub / github.com/nodejs/node / isTypeParameterPossiblyReferenced

Function isTypeParameterPossiblyReferenced

test/fixtures/snapshot/typescript.js:63456–63488  ·  view source on GitHub ↗
(tp, node)

Source from the content-addressed store, hash-verified

63454 node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
63455 }
63456 function isTypeParameterPossiblyReferenced(tp, node) {
63457 // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks
63458 // between the node and the type parameter declaration, if the node contains actual references to the
63459 // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
63460 if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
63461 var container = tp.symbol.declarations[0].parent;
63462 for (var n = node; n !== container; n = n.parent) {
63463 if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) {
63464 return true;
63465 }
63466 }
63467 return containsReference(node);
63468 }
63469 return true;
63470 function containsReference(node) {
63471 switch (node.kind) {
63472 case 192 /* SyntaxKind.ThisType */:
63473 return !!tp.isThisType;
63474 case 79 /* SyntaxKind.Identifier */:
63475 return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
63476 getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
63477 case 181 /* SyntaxKind.TypeQuery */:
63478 return true;
63479 case 169 /* SyntaxKind.MethodDeclaration */:
63480 case 168 /* SyntaxKind.MethodSignature */:
63481 return !node.type && !!node.body ||
63482 ts.some(node.typeParameters, containsReference) ||
63483 ts.some(node.parameters, containsReference) ||
63484 !!node.type && containsReference(node.type);
63485 }
63486 return !!ts.forEachChild(node, containsReference);
63487 }
63488 }
63489 function getHomomorphicTypeVariable(type) {
63490 var constraintType = getConstraintTypeFromMappedType(type);
63491 if (constraintType.flags & 4194304 /* TypeFlags.Index */) {

Callers 3

isDistributionDependentFunction · 0.85

Calls 2

containsReferenceFunction · 0.85
forEachChildMethod · 0.80

Tested by

no test coverage detected