Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 581937d

Browse filesBrowse files
Aha, no need for infinite type checking
1 parent 1c7ef11 commit 581937d
Copy full SHA for 581937d

File tree

Expand file treeCollapse file tree

1 file changed

+1
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-12
lines changed

‎packages/eslint-plugin/src/rules/no-unnecessary-type-parameters.ts

Copy file name to clipboardExpand all lines: packages/eslint-plugin/src/rules/no-unnecessary-type-parameters.ts
+1-12Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ function collectTypeParameterUsageCounts(
118118
): void {
119119
const visitedSymbolLists = new Set<ts.Symbol[]>();
120120
const type = checker.getTypeAtLocation(node);
121-
const typeCounts = new Map<ts.Type, number>();
122121
const visitedConstraints = new Set<ts.TypeNode>();
123122
let functionLikeType = false;
124123
let visitedDefault = false;
@@ -140,11 +139,7 @@ function collectTypeParameterUsageCounts(
140139
area: IdentifierArea,
141140
asRepeatedType: boolean,
142141
): void {
143-
// Seeing the same type > (threshold=3 ** 2) times indicates a likely
144-
// recursive type, like `T = { [P in keyof T]: T }`.
145-
// If it's not recursive, then heck, we've seen it enough times that any
146-
// referenced types have been counted enough to qualify as used.
147-
if (!type || incrementTypeCount(type) > 9) {
142+
if (!type) {
148143
return;
149144
}
150145

@@ -268,12 +263,6 @@ function collectTypeParameterUsageCounts(
268263
identifierCounts.set(id, identifierCount);
269264
}
270265

271-
function incrementTypeCount(type: ts.Type): number {
272-
const count = (typeCounts.get(type) ?? 0) + 1;
273-
typeCounts.set(type, count);
274-
return count;
275-
}
276-
277266
function visitSignature(
278267
signature: ts.Signature | undefined,
279268
area: IdentifierArea,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.