tstyche 6.0.1 → 6.0.2
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.
- package/dist/tstyche.js +41 -26
- package/package.json +1 -1
package/dist/tstyche.js
CHANGED
|
@@ -4656,26 +4656,12 @@ function isReadonlyProperty(symbol, compiler) {
|
|
|
4656
4656
|
(symbol.flags & compiler.SymbolFlags.Accessor && !(symbol.flags & compiler.SymbolFlags.SetAccessor)));
|
|
4657
4657
|
}
|
|
4658
4658
|
|
|
4659
|
-
class SeenService {
|
|
4660
|
-
#cache = new Map();
|
|
4661
|
-
memoized(a, b, compare) {
|
|
4662
|
-
const key = [a.id, b.id].sort().join(":");
|
|
4663
|
-
const result = this.#cache.get(key);
|
|
4664
|
-
if (result !== undefined) {
|
|
4665
|
-
return result !== 2;
|
|
4666
|
-
}
|
|
4667
|
-
this.#cache.set(key, 0);
|
|
4668
|
-
const isSame = compare();
|
|
4669
|
-
this.#cache.set(key, isSame ? 1 : 2);
|
|
4670
|
-
return isSame;
|
|
4671
|
-
}
|
|
4672
|
-
}
|
|
4673
|
-
|
|
4674
4659
|
class Structure {
|
|
4675
4660
|
#compiler;
|
|
4676
4661
|
#compilerOptions;
|
|
4677
|
-
#seen = new SeenService();
|
|
4678
4662
|
#typeChecker;
|
|
4663
|
+
#deduplicateCache = new WeakMap();
|
|
4664
|
+
#memoizeCache = new Map();
|
|
4679
4665
|
constructor(compiler, program) {
|
|
4680
4666
|
this.#compiler = compiler;
|
|
4681
4667
|
this.#compilerOptions = program.getCompilerOptions();
|
|
@@ -4712,7 +4698,7 @@ class Structure {
|
|
|
4712
4698
|
return false;
|
|
4713
4699
|
}
|
|
4714
4700
|
if ((a.flags & b.flags) | this.#compiler.TypeFlags.StructuredType) {
|
|
4715
|
-
return this.#
|
|
4701
|
+
return this.#memoize(a, b, () => this.compareStructuredTypes(a, b));
|
|
4716
4702
|
}
|
|
4717
4703
|
return false;
|
|
4718
4704
|
}
|
|
@@ -4724,7 +4710,7 @@ class Structure {
|
|
|
4724
4710
|
}
|
|
4725
4711
|
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Object) {
|
|
4726
4712
|
if (a.flags & b.flags & this.#compiler.TypeFlags.Object) {
|
|
4727
|
-
return this.#
|
|
4713
|
+
return this.#memoize(a, b, () => this.compareObjects(a, b));
|
|
4728
4714
|
}
|
|
4729
4715
|
return false;
|
|
4730
4716
|
}
|
|
@@ -4773,16 +4759,20 @@ class Structure {
|
|
|
4773
4759
|
return false;
|
|
4774
4760
|
}
|
|
4775
4761
|
compareIntersections(a, b) {
|
|
4776
|
-
|
|
4762
|
+
const aTypes = this.#deduplicate(a);
|
|
4763
|
+
const bTypes = this.#deduplicate(b);
|
|
4764
|
+
if (aTypes.length !== bTypes.length) {
|
|
4777
4765
|
return false;
|
|
4778
4766
|
}
|
|
4779
|
-
return
|
|
4767
|
+
return aTypes.every((aType, i) => this.compare(aType, bTypes[i]));
|
|
4780
4768
|
}
|
|
4781
4769
|
compareUnions(a, b) {
|
|
4782
|
-
|
|
4770
|
+
const aTypes = this.#deduplicate(a);
|
|
4771
|
+
const bTypes = this.#deduplicate(b);
|
|
4772
|
+
if (aTypes.length !== bTypes.length) {
|
|
4783
4773
|
return false;
|
|
4784
4774
|
}
|
|
4785
|
-
return
|
|
4775
|
+
return aTypes.every((aType) => bTypes.some((bType) => this.compare(aType, bType)));
|
|
4786
4776
|
}
|
|
4787
4777
|
compareObjects(a, b) {
|
|
4788
4778
|
if (a.objectFlags & b.objectFlags & this.#compiler.ObjectFlags.Reference) {
|
|
@@ -5037,14 +5027,39 @@ class Structure {
|
|
|
5037
5027
|
}
|
|
5038
5028
|
return true;
|
|
5039
5029
|
}
|
|
5030
|
+
#deduplicate(target) {
|
|
5031
|
+
let result = this.#deduplicateCache.get(target);
|
|
5032
|
+
if (result) {
|
|
5033
|
+
return result;
|
|
5034
|
+
}
|
|
5035
|
+
result = target.types.slice(0, 1);
|
|
5036
|
+
for (let i = 1; i < target.types.length; i++) {
|
|
5037
|
+
if (!result.some((existing) => this.compare(existing, target.types[i]))) {
|
|
5038
|
+
result.push(target.types[i]);
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
this.#deduplicateCache.set(target, result);
|
|
5042
|
+
return result;
|
|
5043
|
+
}
|
|
5044
|
+
#memoize(a, b, compare) {
|
|
5045
|
+
const key = [a.id, b.id].sort().join(":");
|
|
5046
|
+
const result = this.#memoizeCache.get(key);
|
|
5047
|
+
if (result !== undefined) {
|
|
5048
|
+
return result !== 2;
|
|
5049
|
+
}
|
|
5050
|
+
this.#memoizeCache.set(key, 0);
|
|
5051
|
+
const isSame = compare();
|
|
5052
|
+
this.#memoizeCache.set(key, isSame ? 1 : 2);
|
|
5053
|
+
return isSame;
|
|
5054
|
+
}
|
|
5040
5055
|
#normalize(type) {
|
|
5041
5056
|
if (type.flags & this.#compiler.TypeFlags.Freshable && type.freshType === type) {
|
|
5042
5057
|
return type.regularType;
|
|
5043
5058
|
}
|
|
5044
5059
|
if (type.flags & this.#compiler.TypeFlags.UnionOrIntersection) {
|
|
5045
|
-
const
|
|
5046
|
-
if (
|
|
5047
|
-
return
|
|
5060
|
+
const parts = this.#deduplicate(type);
|
|
5061
|
+
if (parts.length === 1) {
|
|
5062
|
+
return parts.at(0);
|
|
5048
5063
|
}
|
|
5049
5064
|
}
|
|
5050
5065
|
return type;
|
|
@@ -5905,7 +5920,7 @@ class FileRunner {
|
|
|
5905
5920
|
class Runner {
|
|
5906
5921
|
#eventEmitter = new EventEmitter();
|
|
5907
5922
|
#resolvedConfig;
|
|
5908
|
-
static version = "6.0.
|
|
5923
|
+
static version = "6.0.2";
|
|
5909
5924
|
constructor(resolvedConfig) {
|
|
5910
5925
|
this.#resolvedConfig = resolvedConfig;
|
|
5911
5926
|
}
|