@typescript-eslint/eslint-plugin 8.71.1-alpha.13 → 8.71.1-alpha.14

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.
@@ -353,9 +353,24 @@ function collectTypeParameterUsageCounts(checker, node, foundIdentifierUsages, f
353
353
  // TS treats mapped types like `{[k in "a"]: T}` like `{a: T}`.
354
354
  // They have properties, so we need to avoid double-counting.
355
355
  visitType(type.templateType ?? type.constraintType, false);
356
+ // `templateType` is a lazily populated checker cache. Once it is
357
+ // populated on an instantiated mapped type, its constraint is
358
+ // reachable only here: the type parameter's declaration holds the
359
+ // original constraint from before instantiation.
360
+ if (type.templateType &&
361
+ type.constraintType &&
362
+ type.constraintType !==
363
+ getDeclaredConstraintType(type.typeParameter)) {
364
+ visitType(type.constraintType, false);
365
+ }
356
366
  }
357
367
  // TS doesn't count mapped types key remapping (`{[K in 'a' as T]: K}`)
358
368
  // but handles this under `MappedType.nameType`, so we need to visit that too.
369
+ // Instantiated mapped types populate it lazily, which getting the
370
+ // awaited type forces.
371
+ if (!type.nameType) {
372
+ checker.getAwaitedType(type);
373
+ }
359
374
  if (type.nameType) {
360
375
  visitType(type.nameType, false);
361
376
  }
@@ -386,6 +401,13 @@ function collectTypeParameterUsageCounts(checker, node, foundIdentifierUsages, f
386
401
  typeUsages.set(type, count);
387
402
  return count;
388
403
  }
404
+ function getDeclaredConstraintType(typeParameter) {
405
+ const constraint = typeParameter
406
+ ?.getSymbol()
407
+ ?.getDeclarations()
408
+ ?.find(ts.isTypeParameterDeclaration)?.constraint;
409
+ return constraint && checker.getTypeAtLocation(constraint);
410
+ }
389
411
  function visitSignature(signature) {
390
412
  if (!signature) {
391
413
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.71.1-alpha.13",
3
+ "version": "8.71.1-alpha.14",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@eslint-community/regexpp": "^4.12.2",
50
- "@typescript-eslint/scope-manager": "8.71.1-alpha.13",
51
- "@typescript-eslint/type-utils": "8.71.1-alpha.13",
52
- "@typescript-eslint/utils": "8.71.1-alpha.13",
53
- "@typescript-eslint/visitor-keys": "8.71.1-alpha.13",
50
+ "@typescript-eslint/scope-manager": "8.71.1-alpha.14",
51
+ "@typescript-eslint/type-utils": "8.71.1-alpha.14",
52
+ "@typescript-eslint/utils": "8.71.1-alpha.14",
53
+ "@typescript-eslint/visitor-keys": "8.71.1-alpha.14",
54
54
  "ignore": "^7.0.5",
55
55
  "natural-compare": "^1.4.0",
56
56
  "ts-api-utils": "^2.5.0"
@@ -60,8 +60,8 @@
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/natural-compare": "^1.4.3",
62
62
  "@types/react": "^18.3.21",
63
- "@typescript-eslint/rule-schema-to-typescript-types": "8.71.1-alpha.13",
64
- "@typescript-eslint/rule-tester": "8.71.1-alpha.13",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.71.1-alpha.14",
64
+ "@typescript-eslint/rule-tester": "8.71.1-alpha.14",
65
65
  "@typescript/native": "npm:typescript@^7.0.2",
66
66
  "@vitest/coverage-v8": "^4.0.18",
67
67
  "ajv": "^6.12.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^4.0.18"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.71.1-alpha.13",
84
+ "@typescript-eslint/parser": "^8.71.1-alpha.14",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },