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

Function getRecursionIdentity

test/fixtures/snapshot/typescript.js:67210–67244  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

67208 // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly
67209 // reference the type have a recursion identity that differs from the object identity.
67210 function getRecursionIdentity(type) {
67211 // Object and array literals are known not to contain recursive references and don't need a recursion identity.
67212 if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) {
67213 if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) {
67214 // Deferred type references are tracked through their associated AST node. This gives us finer
67215 // granularity than using their associated target because each manifest type reference has a
67216 // unique AST node.
67217 return type.node;
67218 }
67219 if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) {
67220 // We track all object types that have an associated symbol (representing the origin of the type), but
67221 // exclude the static side of classes from this check since it shares its symbol with the instance side.
67222 return type.symbol;
67223 }
67224 if (isTupleType(type)) {
67225 // Tuple types are tracked through their target type
67226 return type.target;
67227 }
67228 }
67229 if (type.flags & 262144 /* TypeFlags.TypeParameter */) {
67230 return type.symbol;
67231 }
67232 if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) {
67233 // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A
67234 do {
67235 type = type.objectType;
67236 } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */);
67237 return type;
67238 }
67239 if (type.flags & 16777216 /* TypeFlags.Conditional */) {
67240 // The root object represents the origin of the conditional type
67241 return type.root;
67242 }
67243 return type;
67244 }
67245 function isPropertyIdenticalTo(sourceProp, targetProp) {
67246 return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */;
67247 }

Callers 3

isDeeplyNestedTypeFunction · 0.85
invokeOnceFunction · 0.85

Calls 2

isTupleTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…