MCPcopy Index your code
hub / github.com/nodejs/node / getTypeReferenceId

Function getTypeReferenceId

test/fixtures/snapshot/typescript.js:67081–67107  ·  view source on GitHub ↗
(type, depth)

Source from the content-addressed store, hash-verified

67079 // getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
67080 // where A.id=111 and number.id=12
67081 function getTypeReferenceId(type, depth) {
67082 if (depth === void 0) { depth = 0; }
67083 var result = "" + type.target.id;
67084 for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
67085 var t = _a[_i];
67086 if (t.flags & 262144 /* TypeFlags.TypeParameter */) {
67087 if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
67088 var index = typeParameters.indexOf(t);
67089 if (index < 0) {
67090 index = typeParameters.length;
67091 typeParameters.push(t);
67092 }
67093 result += "=" + index;
67094 continue;
67095 }
67096 // We mark type references that reference constrained type parameters such that we know to obtain
67097 // and look for a "broadest equivalent key" in the cache.
67098 constraintMarker = "*";
67099 }
67100 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
67101 result += "<" + getTypeReferenceId(t, depth + 1) + ">";
67102 continue;
67103 }
67104 result += "-" + t.id;
67105 }
67106 return result;
67107 }
67108 }
67109 /**
67110 * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.

Callers 1

Calls 5

getTypeArgumentsFunction · 0.85
indexOfMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…