tstyche 7.2.4 → 7.2.5
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/api.js +39 -5
- 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.
|
|
615
|
+
request.headers.set("User-Agent", `tstyche/7.2.5 ${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;
|
|
@@ -4782,6 +4782,7 @@ class Structure {
|
|
|
4782
4782
|
#deduplicateCache = new WeakMap();
|
|
4783
4783
|
#memoizeCache = new Map();
|
|
4784
4784
|
#recursionStack = [];
|
|
4785
|
+
#unusedTypeParametersLookup = new WeakMap();
|
|
4785
4786
|
constructor(compiler, program) {
|
|
4786
4787
|
this.#compiler = compiler;
|
|
4787
4788
|
this.#compilerOptions = program.getCompilerOptions();
|
|
@@ -4924,10 +4925,11 @@ class Structure {
|
|
|
4924
4925
|
if (this.compare(a.target, b.target)) {
|
|
4925
4926
|
const aTypeArguments = this.#typeChecker.getTypeArguments(a);
|
|
4926
4927
|
const bTypeArguments = this.#typeChecker.getTypeArguments(b);
|
|
4927
|
-
|
|
4928
|
-
return false;
|
|
4929
|
-
}
|
|
4928
|
+
const unusedTypeParameters = this.#getUnusedTypeParameterIndexes(a.target);
|
|
4930
4929
|
for (let i = 0; i < aTypeArguments.length; i++) {
|
|
4930
|
+
if (unusedTypeParameters.has(i)) {
|
|
4931
|
+
continue;
|
|
4932
|
+
}
|
|
4931
4933
|
if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
|
|
4932
4934
|
return false;
|
|
4933
4935
|
}
|
|
@@ -4936,6 +4938,38 @@ class Structure {
|
|
|
4936
4938
|
}
|
|
4937
4939
|
return this.compareStructures(a, b);
|
|
4938
4940
|
}
|
|
4941
|
+
#getUnusedTypeParameterIndexes(type) {
|
|
4942
|
+
const result = new Set();
|
|
4943
|
+
if (type.typeParameters != null) {
|
|
4944
|
+
const symbol = type.getSymbol();
|
|
4945
|
+
const declarations = symbol?.getDeclarations();
|
|
4946
|
+
if (symbol != null && declarations != null) {
|
|
4947
|
+
const cached = this.#unusedTypeParametersLookup.get(symbol);
|
|
4948
|
+
if (cached != null) {
|
|
4949
|
+
return cached;
|
|
4950
|
+
}
|
|
4951
|
+
for (let i = 0; i < type.typeParameters.length; i++) {
|
|
4952
|
+
const symbol = type.typeParameters[i].getSymbol();
|
|
4953
|
+
const identifier = symbol.declarations[0].name;
|
|
4954
|
+
const isUsed = declarations.some((declaration) => this.#isSymbolUsedIn(declaration, symbol, identifier));
|
|
4955
|
+
if (!isUsed) {
|
|
4956
|
+
result.add(i);
|
|
4957
|
+
}
|
|
4958
|
+
}
|
|
4959
|
+
this.#unusedTypeParametersLookup.set(symbol, result);
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
return result;
|
|
4963
|
+
}
|
|
4964
|
+
#isSymbolUsedIn(node, symbol, identifier, enclosingNode = node) {
|
|
4965
|
+
if (node === identifier || (this.#compiler.isTypeParameterDeclaration(node) && node.parent === enclosingNode)) {
|
|
4966
|
+
return false;
|
|
4967
|
+
}
|
|
4968
|
+
if (this.#compiler.isIdentifier(node) && this.#typeChecker.getSymbolAtLocation(node) === symbol) {
|
|
4969
|
+
return true;
|
|
4970
|
+
}
|
|
4971
|
+
return node.forEachChild((child) => this.#isSymbolUsedIn(child, symbol, identifier, enclosingNode)) ?? false;
|
|
4972
|
+
}
|
|
4939
4973
|
compareTuples(a, b) {
|
|
4940
4974
|
if (a.target.readonly !== b.target.readonly) {
|
|
4941
4975
|
return false;
|
|
@@ -5942,7 +5976,7 @@ class FileRunner {
|
|
|
5942
5976
|
class Runner {
|
|
5943
5977
|
#eventEmitter = new EventEmitter();
|
|
5944
5978
|
#resolvedConfig;
|
|
5945
|
-
static version = "7.2.
|
|
5979
|
+
static version = "7.2.5";
|
|
5946
5980
|
constructor(resolvedConfig) {
|
|
5947
5981
|
this.#resolvedConfig = resolvedConfig;
|
|
5948
5982
|
}
|