(type, transform)
| 52764 | } |
| 52765 | } |
| 52766 | function visitAndTransformType(type, transform) { |
| 52767 | var _a, _b; |
| 52768 | var typeId = type.id; |
| 52769 | var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; |
| 52770 | var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : |
| 52771 | type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : |
| 52772 | type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : |
| 52773 | undefined; |
| 52774 | // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead |
| 52775 | // of types allows us to catch circular references to instantiations of the same anonymous type |
| 52776 | if (!context.visitedTypes) { |
| 52777 | context.visitedTypes = new ts.Set(); |
| 52778 | } |
| 52779 | if (id && !context.symbolDepth) { |
| 52780 | context.symbolDepth = new ts.Map(); |
| 52781 | } |
| 52782 | var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); |
| 52783 | var key = "".concat(getTypeId(type), "|").concat(context.flags); |
| 52784 | if (links) { |
| 52785 | links.serializedTypes || (links.serializedTypes = new ts.Map()); |
| 52786 | } |
| 52787 | var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); |
| 52788 | if (cachedResult) { |
| 52789 | if (cachedResult.truncating) { |
| 52790 | context.truncating = true; |
| 52791 | } |
| 52792 | context.approximateLength += cachedResult.addedLength; |
| 52793 | return deepCloneOrReuseNode(cachedResult); |
| 52794 | } |
| 52795 | var depth; |
| 52796 | if (id) { |
| 52797 | depth = context.symbolDepth.get(id) || 0; |
| 52798 | if (depth > 10) { |
| 52799 | return createElidedInformationPlaceholder(context); |
| 52800 | } |
| 52801 | context.symbolDepth.set(id, depth + 1); |
| 52802 | } |
| 52803 | context.visitedTypes.add(typeId); |
| 52804 | var startLength = context.approximateLength; |
| 52805 | var result = transform(type); |
| 52806 | var addedLength = context.approximateLength - startLength; |
| 52807 | if (!context.reportedDiagnostic && !context.encounteredError) { |
| 52808 | if (context.truncating) { |
| 52809 | result.truncating = true; |
| 52810 | } |
| 52811 | result.addedLength = addedLength; |
| 52812 | (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); |
| 52813 | } |
| 52814 | context.visitedTypes.delete(typeId); |
| 52815 | if (id) { |
| 52816 | context.symbolDepth.set(id, depth); |
| 52817 | } |
| 52818 | return result; |
| 52819 | function deepCloneOrReuseNode(node) { |
| 52820 | if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { |
| 52821 | return node; |
| 52822 | } |
| 52823 | return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node); |
no test coverage detected
searching dependent graphs…