@typescript-eslint/eslint-plugin 8.72.1-alpha.1 → 8.72.1-alpha.10

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.
@@ -37,6 +37,7 @@ const utils_1 = require("@typescript-eslint/utils");
37
37
  const tsutils = __importStar(require("ts-api-utils"));
38
38
  const ts = __importStar(require("typescript"));
39
39
  const util_1 = require("../util");
40
+ const MAX_TYPE_CONTAINS_DEPTH = 50;
40
41
  exports.default = (0, util_1.createRule)({
41
42
  name: 'no-unnecessary-type-assertion',
42
43
  meta: {
@@ -228,8 +229,9 @@ exports.default = (0, util_1.createRule)({
228
229
  return (type.aliasTypeArguments ??
229
230
  (tsutils.isTypeReference(type) ? checker.getTypeArguments(type) : []));
230
231
  }
231
- function typeContains(type, predicate, seen = new Set()) {
232
- if (seen.has(type)) {
232
+ // Recursive generic types instantiate new types forever, so give up past a fixed depth (#12705).
233
+ function typeContains(type, predicate, seen = new Set(), depth = 0) {
234
+ if (seen.has(type) || depth > MAX_TYPE_CONTAINS_DEPTH) {
233
235
  return false;
234
236
  }
235
237
  seen.add(type);
@@ -237,7 +239,7 @@ exports.default = (0, util_1.createRule)({
237
239
  return true;
238
240
  }
239
241
  if (type.isUnionOrIntersection()) {
240
- return type.types.some(t => typeContains(t, predicate, seen));
242
+ return type.types.some(t => typeContains(t, predicate, seen, depth + 1));
241
243
  }
242
244
  const nestedTypes = [
243
245
  ...getTypeArguments(type),
@@ -248,20 +250,10 @@ exports.default = (0, util_1.createRule)({
248
250
  ...sig.getParameters().map(p => checker.getTypeOfSymbol(p)),
249
251
  ]),
250
252
  ];
251
- return nestedTypes.some(t => typeContains(t, predicate, seen));
253
+ return nestedTypes.some(t => typeContains(t, predicate, seen, depth + 1));
252
254
  }
253
255
  function containsAny(type) {
254
- try {
255
- return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Any));
256
- }
257
- catch (error) {
258
- // Workaround for https://github.com/typescript-eslint/typescript-eslint/issues/12705
259
- if (error instanceof RangeError &&
260
- error.message === 'Maximum call stack size exceeded') {
261
- return false;
262
- }
263
- throw error;
264
- }
256
+ return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Any));
265
257
  }
266
258
  function containsTypeVariable(type) {
267
259
  return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.TypeVariable | ts.TypeFlags.Index));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.72.1-alpha.1",
3
+ "version": "8.72.1-alpha.10",
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.72.1-alpha.1",
51
- "@typescript-eslint/type-utils": "8.72.1-alpha.1",
52
- "@typescript-eslint/utils": "8.72.1-alpha.1",
53
- "@typescript-eslint/visitor-keys": "8.72.1-alpha.1",
50
+ "@typescript-eslint/scope-manager": "8.72.1-alpha.10",
51
+ "@typescript-eslint/type-utils": "8.72.1-alpha.10",
52
+ "@typescript-eslint/utils": "8.72.1-alpha.10",
53
+ "@typescript-eslint/visitor-keys": "8.72.1-alpha.10",
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.72.1-alpha.1",
64
- "@typescript-eslint/rule-tester": "8.72.1-alpha.1",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.72.1-alpha.10",
64
+ "@typescript-eslint/rule-tester": "8.72.1-alpha.10",
65
65
  "@typescript/native": "npm:typescript@^7.0.2",
66
66
  "@vitest/coverage-v8": "^5.0.3",
67
67
  "ajv": "^6.12.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^5.0.3"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.72.1-alpha.1",
84
+ "@typescript-eslint/parser": "^8.72.1-alpha.10",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },