@typescript-eslint/type-utils 8.70.1-alpha.9 → 8.70.2-alpha.0

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.
@@ -53,14 +53,26 @@ function findParentModuleDeclaration(node) {
53
53
  function typeDeclaredInDeclareModule(packageName, declarations) {
54
54
  return declarations.some(declaration => findParentModuleDeclaration(declaration)?.name.text === packageName);
55
55
  }
56
+ /**
57
+ * Whether `packagePath` is `packageName` itself or something inside it, comparing
58
+ * whole path components: `semver` covers `semver` and `semver/classes/semver.d.ts`,
59
+ * but not `semver-compare` or `my-semver`.
60
+ */
61
+ function pathIsInPackage(packagePath, packageName) {
62
+ return (packagePath === packageName || packagePath.startsWith(`${packageName}/`));
63
+ }
56
64
  function typeDeclaredInDeclarationFile(packageName, declarationFiles, program) {
57
65
  // Handle scoped packages: if the name starts with @, remove it and replace / with __
58
66
  const typesPackageName = packageName.replace(/^@([^/]+)\//, '$1__');
59
- const matcher = new RegExp(`${packageName}|${typesPackageName}`);
60
67
  return declarationFiles.some(declaration => {
68
+ // A package id name is a path within the package, such as
69
+ // `typescript/lib/typescript.d.ts` or `@types/semver/classes/semver.d.ts`.
61
70
  const packageIdName = program.sourceFileToPackageName.get(declaration.path);
62
- return (packageIdName != null &&
63
- matcher.test(packageIdName) &&
71
+ if (packageIdName == null) {
72
+ return false;
73
+ }
74
+ return ((pathIsInPackage(packageIdName, packageName) ||
75
+ pathIsInPackage(packageIdName.replace(/^@types\//, ''), typesPackageName)) &&
64
76
  program.isSourceFileFromExternalLibrary(declaration));
65
77
  });
66
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/type-utils",
3
- "version": "8.70.1-alpha.9",
3
+ "version": "8.70.2-alpha.0",
4
4
  "description": "Type utilities for working with TypeScript + ESLint together",
5
5
  "files": [
6
6
  "dist",
@@ -34,9 +34,9 @@
34
34
  "estree"
35
35
  ],
36
36
  "dependencies": {
37
- "@typescript-eslint/types": "8.70.1-alpha.9",
38
- "@typescript-eslint/typescript-estree": "8.70.1-alpha.9",
39
- "@typescript-eslint/utils": "8.70.1-alpha.9",
37
+ "@typescript-eslint/types": "8.70.2-alpha.0",
38
+ "@typescript-eslint/typescript-estree": "8.70.2-alpha.0",
39
+ "@typescript-eslint/utils": "8.70.2-alpha.0",
40
40
  "debug": "^4.4.3",
41
41
  "ts-api-utils": "^2.5.0"
42
42
  },
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/babel__code-frame": "^7.0.6",
49
- "@typescript-eslint/parser": "8.70.1-alpha.9",
49
+ "@typescript-eslint/parser": "8.70.2-alpha.0",
50
50
  "@typescript/native": "npm:typescript@^7.0.2",
51
51
  "@vitest/coverage-v8": "^4.0.18",
52
52
  "ajv": "^6.12.6",