tstyche 7.2.3 → 7.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/api.js +35 -2
  2. package/package.json +1 -1
package/dist/api.js CHANGED
@@ -612,7 +612,7 @@ class Fetcher {
612
612
  }
613
613
  async get(request, diagnostic, options) {
614
614
  let delay = 3000;
615
- request.headers.set("User-Agent", `tstyche/7.2.3 ${process.platform} ${process.arch}`);
615
+ request.headers.set("User-Agent", `tstyche/7.2.4 ${process.platform} ${process.arch}`);
616
616
  for (let attempt = 0; attempt <= this.#retries; attempt++) {
617
617
  const isLastAttempt = attempt === this.#retries;
618
618
  const suppressErrors = options?.suppressErrors || !isLastAttempt;
@@ -4781,6 +4781,7 @@ class Structure {
4781
4781
  #typeChecker;
4782
4782
  #deduplicateCache = new WeakMap();
4783
4783
  #memoizeCache = new Map();
4784
+ #recursionStack = [];
4784
4785
  constructor(compiler, program) {
4785
4786
  this.#compiler = compiler;
4786
4787
  this.#compilerOptions = program.getCompilerOptions();
@@ -5159,14 +5160,46 @@ class Structure {
5159
5160
  this.#deduplicateCache.set(target, result);
5160
5161
  return result;
5161
5162
  }
5163
+ #getRecursionIdentity(type) {
5164
+ return type.aliasSymbol ?? type.symbol;
5165
+ }
5166
+ #isInfiniteRecursion(a, b) {
5167
+ const aIdentity = this.#getRecursionIdentity(a);
5168
+ const bIdentity = this.#getRecursionIdentity(b);
5169
+ if (!aIdentity || !bIdentity) {
5170
+ return false;
5171
+ }
5172
+ let matches = 0;
5173
+ for (const frame of this.#recursionStack) {
5174
+ if (frame.aIdentity === aIdentity && frame.bIdentity === bIdentity && a.id > frame.aId && b.id > frame.bId) {
5175
+ matches++;
5176
+ if (matches >= 2) {
5177
+ return true;
5178
+ }
5179
+ }
5180
+ }
5181
+ return false;
5182
+ }
5162
5183
  #memoize(a, b, compare) {
5163
5184
  const key = [a.id, b.id].sort((a, b) => a - b).join(":");
5164
5185
  const result = this.#memoizeCache.get(key);
5165
5186
  if (result !== undefined) {
5166
5187
  return result !== 2;
5167
5188
  }
5189
+ if (this.#isInfiniteRecursion(a, b)) {
5190
+ this.#memoizeCache.set(key, 1);
5191
+ return true;
5192
+ }
5168
5193
  this.#memoizeCache.set(key, 0);
5194
+ const aIdentity = this.#getRecursionIdentity(a);
5195
+ const bIdentity = this.#getRecursionIdentity(b);
5196
+ if (aIdentity != null && bIdentity != null) {
5197
+ this.#recursionStack.push({ aId: a.id, bId: b.id, aIdentity, bIdentity });
5198
+ }
5169
5199
  const isSame = compare();
5200
+ if (aIdentity != null && bIdentity != null) {
5201
+ this.#recursionStack.pop();
5202
+ }
5170
5203
  this.#memoizeCache.set(key, isSame ? 1 : 2);
5171
5204
  return isSame;
5172
5205
  }
@@ -5909,7 +5942,7 @@ class FileRunner {
5909
5942
  class Runner {
5910
5943
  #eventEmitter = new EventEmitter();
5911
5944
  #resolvedConfig;
5912
- static version = "7.2.3";
5945
+ static version = "7.2.4";
5913
5946
  constructor(resolvedConfig) {
5914
5947
  this.#resolvedConfig = resolvedConfig;
5915
5948
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "7.2.3",
3
+ "version": "7.2.4",
4
4
  "description": "Everything You Need for Type Testing.",
5
5
  "keywords": [
6
6
  "typescript",