@typescript-eslint/type-utils 8.71.3-alpha.0 → 8.71.3-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.
|
@@ -39,8 +39,7 @@ exports.valueMatchesSpecifier = valueMatchesSpecifier;
|
|
|
39
39
|
const types_1 = require("@typescript-eslint/types");
|
|
40
40
|
const tsutils = __importStar(require("ts-api-utils"));
|
|
41
41
|
const specifierNameMatches_1 = require("./typeOrValueSpecifiers/specifierNameMatches");
|
|
42
|
-
const
|
|
43
|
-
const typeDeclaredInLib_1 = require("./typeOrValueSpecifiers/typeDeclaredInLib");
|
|
42
|
+
const specifierSourceMatches_1 = require("./typeOrValueSpecifiers/specifierSourceMatches");
|
|
44
43
|
const typeDeclaredInPackageDeclarationFile_1 = require("./typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile");
|
|
45
44
|
exports.typeOrValueSpecifiersSchema = {
|
|
46
45
|
items: {
|
|
@@ -150,17 +149,7 @@ function typeMatchesSpecifier(type, specifier, program) {
|
|
|
150
149
|
if (!(0, specifierNameMatches_1.specifierNameMatches)(type, specifier.name)) {
|
|
151
150
|
return false;
|
|
152
151
|
}
|
|
153
|
-
|
|
154
|
-
const declarations = symbol?.getDeclarations() ?? [];
|
|
155
|
-
const declarationFiles = declarations.map(declaration => declaration.getSourceFile());
|
|
156
|
-
switch (specifier.from) {
|
|
157
|
-
case 'file':
|
|
158
|
-
return (0, typeDeclaredInFile_1.typeDeclaredInFile)(specifier.path, declarationFiles, program);
|
|
159
|
-
case 'lib':
|
|
160
|
-
return (0, typeDeclaredInLib_1.typeDeclaredInLib)(declarationFiles, program);
|
|
161
|
-
case 'package':
|
|
162
|
-
return (0, typeDeclaredInPackageDeclarationFile_1.typeDeclaredInPackageDeclarationFile)(specifier.package, symbol, declarations, declarationFiles, program);
|
|
163
|
-
}
|
|
152
|
+
return (0, specifierSourceMatches_1.specifierSourceMatches)(specifier, type.getSymbol() ?? type.aliasSymbol, program);
|
|
164
153
|
})();
|
|
165
154
|
if (wholeTypeMatches) {
|
|
166
155
|
return true;
|
package/dist/isTypeReadonly.js
CHANGED
|
@@ -40,6 +40,7 @@ const tsutils = __importStar(require("ts-api-utils"));
|
|
|
40
40
|
const ts = __importStar(require("typescript"));
|
|
41
41
|
const propertyTypes_1 = require("./propertyTypes");
|
|
42
42
|
const TypeOrValueSpecifier_1 = require("./TypeOrValueSpecifier");
|
|
43
|
+
const specifierSourceMatches_1 = require("./typeOrValueSpecifiers/specifierSourceMatches");
|
|
43
44
|
var Readonlyness;
|
|
44
45
|
(function (Readonlyness) {
|
|
45
46
|
/** the type cannot be handled by the function */
|
|
@@ -180,11 +181,14 @@ function isTypeReadonlyRecurser(program, type, options, seenTypes) {
|
|
|
180
181
|
if (type.aliasSymbol && options.allow) {
|
|
181
182
|
const aliasSymbol = type.aliasSymbol;
|
|
182
183
|
const aliasMatches = options.allow.some(specifier => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
if (typeof specifier === 'string') {
|
|
185
|
+
return specifier === aliasSymbol.getName();
|
|
186
|
+
}
|
|
187
|
+
const names = Array.isArray(specifier.name)
|
|
188
|
+
? specifier.name
|
|
189
|
+
: [specifier.name];
|
|
190
|
+
return (names.includes(aliasSymbol.getName()) &&
|
|
191
|
+
(0, specifierSourceMatches_1.specifierSourceMatches)(specifier, aliasSymbol, program));
|
|
188
192
|
});
|
|
189
193
|
if (aliasMatches) {
|
|
190
194
|
return Readonlyness.Readonly;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type * as ts from 'typescript';
|
|
2
|
+
import type { FileSpecifier, LibSpecifier, PackageSpecifier } from '../TypeOrValueSpecifier';
|
|
3
|
+
export declare function specifierSourceMatches(specifier: FileSpecifier | LibSpecifier | PackageSpecifier, symbol: ts.Symbol | undefined, program: ts.Program): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.specifierSourceMatches = specifierSourceMatches;
|
|
4
|
+
const typeDeclaredInFile_1 = require("./typeDeclaredInFile");
|
|
5
|
+
const typeDeclaredInLib_1 = require("./typeDeclaredInLib");
|
|
6
|
+
const typeDeclaredInPackageDeclarationFile_1 = require("./typeDeclaredInPackageDeclarationFile");
|
|
7
|
+
function specifierSourceMatches(specifier, symbol, program) {
|
|
8
|
+
const declarations = symbol?.getDeclarations() ?? [];
|
|
9
|
+
const declarationFiles = declarations.map(declaration => declaration.getSourceFile());
|
|
10
|
+
switch (specifier.from) {
|
|
11
|
+
case 'file':
|
|
12
|
+
return (0, typeDeclaredInFile_1.typeDeclaredInFile)(specifier.path, declarationFiles, program);
|
|
13
|
+
case 'lib':
|
|
14
|
+
return (0, typeDeclaredInLib_1.typeDeclaredInLib)(declarationFiles, program);
|
|
15
|
+
case 'package':
|
|
16
|
+
return (0, typeDeclaredInPackageDeclarationFile_1.typeDeclaredInPackageDeclarationFile)(specifier.package, symbol, declarations, declarationFiles, program);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=specifierSourceMatches.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/type-utils",
|
|
3
|
-
"version": "8.71.3-alpha.
|
|
3
|
+
"version": "8.71.3-alpha.10",
|
|
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.71.3-alpha.
|
|
38
|
-
"@typescript-eslint/typescript-estree": "8.71.3-alpha.
|
|
39
|
-
"@typescript-eslint/utils": "8.71.3-alpha.
|
|
37
|
+
"@typescript-eslint/types": "8.71.3-alpha.10",
|
|
38
|
+
"@typescript-eslint/typescript-estree": "8.71.3-alpha.10",
|
|
39
|
+
"@typescript-eslint/utils": "8.71.3-alpha.10",
|
|
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.71.3-alpha.
|
|
49
|
+
"@typescript-eslint/parser": "8.71.3-alpha.10",
|
|
50
50
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
51
51
|
"@vitest/coverage-v8": "^4.0.18",
|
|
52
52
|
"ajv": "^6.12.6",
|