@typescript-eslint/type-utils 8.0.0-alpha.45 → 8.0.0-alpha.47
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.
- package/dist/TypeOrValueSpecifier.d.ts +3 -4
- package/dist/TypeOrValueSpecifier.d.ts.map +1 -1
- package/dist/TypeOrValueSpecifier.js +11 -53
- package/dist/TypeOrValueSpecifier.js.map +1 -1
- package/dist/typeOrValueSpecifiers/specifierNameMatches.d.ts +3 -0
- package/dist/typeOrValueSpecifiers/specifierNameMatches.d.ts.map +1 -0
- package/dist/typeOrValueSpecifiers/specifierNameMatches.js +17 -0
- package/dist/typeOrValueSpecifiers/specifierNameMatches.js.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInFile.d.ts +3 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInFile.d.ts.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInFile.js +17 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInFile.js.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInLib.d.ts +3 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInLib.d.ts.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInLib.js +12 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInLib.js.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.d.ts +3 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.d.ts.map +1 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.js +58 -0
- package/dist/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
interface FileSpecifier {
|
|
3
|
+
export interface FileSpecifier {
|
|
4
4
|
from: 'file';
|
|
5
5
|
name: string[] | string;
|
|
6
6
|
path?: string;
|
|
7
7
|
}
|
|
8
|
-
interface LibSpecifier {
|
|
8
|
+
export interface LibSpecifier {
|
|
9
9
|
from: 'lib';
|
|
10
10
|
name: string[] | string;
|
|
11
11
|
}
|
|
12
|
-
interface PackageSpecifier {
|
|
12
|
+
export interface PackageSpecifier {
|
|
13
13
|
from: 'package';
|
|
14
14
|
name: string[] | string;
|
|
15
15
|
package: string;
|
|
@@ -17,5 +17,4 @@ interface PackageSpecifier {
|
|
|
17
17
|
export type TypeOrValueSpecifier = FileSpecifier | LibSpecifier | PackageSpecifier | string;
|
|
18
18
|
export declare const typeOrValueSpecifierSchema: JSONSchema4;
|
|
19
19
|
export declare function typeMatchesSpecifier(type: ts.Type, specifier: TypeOrValueSpecifier, program: ts.Program): boolean;
|
|
20
|
-
export {};
|
|
21
20
|
//# sourceMappingURL=TypeOrValueSpecifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeOrValueSpecifier.d.ts","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeOrValueSpecifier.d.ts","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAOtC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,oBAAoB,GAC5B,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,MAAM,CAAC;AAEX,eAAO,MAAM,0BAA0B,EAAE,WA0FxC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,OAAO,CA4BT"}
|
|
@@ -22,15 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.typeOrValueSpecifierSchema = void 0;
|
|
30
27
|
exports.typeMatchesSpecifier = typeMatchesSpecifier;
|
|
31
|
-
const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
|
|
32
|
-
const path_1 = __importDefault(require("path"));
|
|
33
28
|
const tsutils = __importStar(require("ts-api-utils"));
|
|
29
|
+
const specifierNameMatches_1 = require("./typeOrValueSpecifiers/specifierNameMatches");
|
|
30
|
+
const typeDeclaredInFile_1 = require("./typeOrValueSpecifiers/typeDeclaredInFile");
|
|
31
|
+
const typeDeclaredInLib_1 = require("./typeOrValueSpecifiers/typeDeclaredInLib");
|
|
32
|
+
const typeDeclaredInPackageDeclarationFile_1 = require("./typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile");
|
|
34
33
|
exports.typeOrValueSpecifierSchema = {
|
|
35
34
|
oneOf: [
|
|
36
35
|
{
|
|
@@ -122,67 +121,26 @@ exports.typeOrValueSpecifierSchema = {
|
|
|
122
121
|
},
|
|
123
122
|
],
|
|
124
123
|
};
|
|
125
|
-
function specifierNameMatches(type, name) {
|
|
126
|
-
if (typeof name === 'string') {
|
|
127
|
-
name = [name];
|
|
128
|
-
}
|
|
129
|
-
if (name.some(item => item === type.intrinsicName)) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
133
|
-
if (symbol === undefined) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
return name.some(item => item === symbol.escapedName);
|
|
137
|
-
}
|
|
138
|
-
function typeDeclaredInFile(relativePath, declarationFiles, program) {
|
|
139
|
-
if (relativePath === undefined) {
|
|
140
|
-
const cwd = (0, typescript_estree_1.getCanonicalFileName)(program.getCurrentDirectory());
|
|
141
|
-
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName).startsWith(cwd));
|
|
142
|
-
}
|
|
143
|
-
const absolutePath = (0, typescript_estree_1.getCanonicalFileName)(path_1.default.join(program.getCurrentDirectory(), relativePath));
|
|
144
|
-
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName) === absolutePath);
|
|
145
|
-
}
|
|
146
|
-
function typeDeclaredInPackage(packageName, declarationFiles, program) {
|
|
147
|
-
// Handle scoped packages - if the name starts with @, remove it and replace / with __
|
|
148
|
-
const typesPackageName = packageName.replace(/^@([^/]+)\//, '$1__');
|
|
149
|
-
const matcher = new RegExp(`${packageName}|${typesPackageName}`);
|
|
150
|
-
return declarationFiles.some(declaration => {
|
|
151
|
-
const packageIdName = program.sourceFileToPackageName.get(declaration.path);
|
|
152
|
-
return (packageIdName !== undefined &&
|
|
153
|
-
matcher.test(packageIdName) &&
|
|
154
|
-
program.isSourceFileFromExternalLibrary(declaration));
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function typeDeclaredInLib(declarationFiles, program) {
|
|
158
|
-
// Assertion: The type is not an error type.
|
|
159
|
-
// Intrinsic type (i.e. string, number, boolean, etc) - Treat it as if it's from lib.
|
|
160
|
-
if (declarationFiles.length === 0) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
return declarationFiles.some(declaration => program.isSourceFileDefaultLibrary(declaration));
|
|
164
|
-
}
|
|
165
124
|
function typeMatchesSpecifier(type, specifier, program) {
|
|
166
125
|
if (tsutils.isIntrinsicErrorType(type)) {
|
|
167
126
|
return false;
|
|
168
127
|
}
|
|
169
128
|
if (typeof specifier === 'string') {
|
|
170
|
-
return specifierNameMatches(type, specifier);
|
|
129
|
+
return (0, specifierNameMatches_1.specifierNameMatches)(type, specifier);
|
|
171
130
|
}
|
|
172
|
-
if (!specifierNameMatches(type, specifier.name)) {
|
|
131
|
+
if (!(0, specifierNameMatches_1.specifierNameMatches)(type, specifier.name)) {
|
|
173
132
|
return false;
|
|
174
133
|
}
|
|
175
134
|
const symbol = type.getSymbol() ?? type.aliasSymbol;
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
?.map(declaration => declaration.getSourceFile()) ?? [];
|
|
135
|
+
const declarations = symbol?.getDeclarations() ?? [];
|
|
136
|
+
const declarationFiles = declarations.map(declaration => declaration.getSourceFile());
|
|
179
137
|
switch (specifier.from) {
|
|
180
138
|
case 'file':
|
|
181
|
-
return typeDeclaredInFile(specifier.path, declarationFiles, program);
|
|
139
|
+
return (0, typeDeclaredInFile_1.typeDeclaredInFile)(specifier.path, declarationFiles, program);
|
|
182
140
|
case 'lib':
|
|
183
|
-
return typeDeclaredInLib(declarationFiles, program);
|
|
141
|
+
return (0, typeDeclaredInLib_1.typeDeclaredInLib)(declarationFiles, program);
|
|
184
142
|
case 'package':
|
|
185
|
-
return
|
|
143
|
+
return (0, typeDeclaredInPackageDeclarationFile_1.typeDeclaredInPackageDeclarationFile)(specifier.package, declarations, declarationFiles, program);
|
|
186
144
|
}
|
|
187
145
|
}
|
|
188
146
|
//# sourceMappingURL=TypeOrValueSpecifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeOrValueSpecifier.js","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeOrValueSpecifier.js","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specifierNameMatches.d.ts","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/specifierNameMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GACtB,OAAO,CAYT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.specifierNameMatches = specifierNameMatches;
|
|
4
|
+
function specifierNameMatches(type, name) {
|
|
5
|
+
if (typeof name === 'string') {
|
|
6
|
+
name = [name];
|
|
7
|
+
}
|
|
8
|
+
if (name.some(item => item === type.intrinsicName)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
12
|
+
if (symbol === undefined) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return name.some(item => item === symbol.escapedName);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=specifierNameMatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specifierNameMatches.js","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/specifierNameMatches.ts"],"names":[],"mappings":";;AAEA,oDAeC;AAfD,SAAgB,oBAAoB,CAClC,IAAa,EACb,IAAuB;IAEvB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAE,IAAoB,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInFile.d.ts","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,gBAAgB,EAAE,EAAE,CAAC,UAAU,EAAE,EACjC,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,OAAO,CAaT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.typeDeclaredInFile = typeDeclaredInFile;
|
|
7
|
+
const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function typeDeclaredInFile(relativePath, declarationFiles, program) {
|
|
10
|
+
if (relativePath === undefined) {
|
|
11
|
+
const cwd = (0, typescript_estree_1.getCanonicalFileName)(program.getCurrentDirectory());
|
|
12
|
+
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName).startsWith(cwd));
|
|
13
|
+
}
|
|
14
|
+
const absolutePath = (0, typescript_estree_1.getCanonicalFileName)(path_1.default.join(program.getCurrentDirectory(), relativePath));
|
|
15
|
+
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName) === absolutePath);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=typeDeclaredInFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInFile.js","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInFile.ts"],"names":[],"mappings":";;;;;AAIA,gDAiBC;AArBD,4EAA4E;AAC5E,gDAAwB;AAGxB,SAAgB,kBAAkB,CAChC,YAAgC,EAChC,gBAAiC,EACjC,OAAmB;IAEnB,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,IAAA,wCAAoB,EAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAChE,OAAO,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CACzC,IAAA,wCAAoB,EAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAC3D,CAAC;IACJ,CAAC;IACD,MAAM,YAAY,GAAG,IAAA,wCAAoB,EACvC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,YAAY,CAAC,CACvD,CAAC;IACF,OAAO,gBAAgB,CAAC,IAAI,CAC1B,WAAW,CAAC,EAAE,CAAC,IAAA,wCAAoB,EAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,YAAY,CAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInLib.d.ts","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInLib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,EAAE,CAAC,UAAU,EAAE,EACjC,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,OAAO,CAUT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typeDeclaredInLib = typeDeclaredInLib;
|
|
4
|
+
function typeDeclaredInLib(declarationFiles, program) {
|
|
5
|
+
// Assertion: The type is not an error type.
|
|
6
|
+
// Intrinsic type (i.e. string, number, boolean, etc) - Treat it as if it's from lib.
|
|
7
|
+
if (declarationFiles.length === 0) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return declarationFiles.some(declaration => program.isSourceFileDefaultLibrary(declaration));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=typeDeclaredInLib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInLib.js","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInLib.ts"],"names":[],"mappings":";;AAEA,8CAaC;AAbD,SAAgB,iBAAiB,CAC/B,gBAAiC,EACjC,OAAmB;IAEnB,4CAA4C;IAE5C,qFAAqF;IACrF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CACzC,OAAO,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
export declare function typeDeclaredInPackageDeclarationFile(packageName: string, declarations: ts.Node[], declarationFiles: ts.SourceFile[], program: ts.Program): boolean;
|
|
3
|
+
//# sourceMappingURL=typeDeclaredInPackageDeclarationFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInPackageDeclarationFile.d.ts","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AA8CjC,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,EAAE,CAAC,IAAI,EAAE,EACvB,gBAAgB,EAAE,EAAE,CAAC,UAAU,EAAE,EACjC,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,OAAO,CAKT"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.typeDeclaredInPackageDeclarationFile = typeDeclaredInPackageDeclarationFile;
|
|
27
|
+
const ts = __importStar(require("typescript"));
|
|
28
|
+
function findParentModuleDeclaration(node) {
|
|
29
|
+
switch (node.kind) {
|
|
30
|
+
case ts.SyntaxKind.ModuleDeclaration:
|
|
31
|
+
return ts.isStringLiteral(node.name)
|
|
32
|
+
? node
|
|
33
|
+
: undefined;
|
|
34
|
+
case ts.SyntaxKind.SourceFile:
|
|
35
|
+
return undefined;
|
|
36
|
+
default:
|
|
37
|
+
return findParentModuleDeclaration(node.parent);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function typeDeclaredInDeclareModule(packageName, declarations) {
|
|
41
|
+
return declarations.some(declaration => findParentModuleDeclaration(declaration)?.name.text === packageName);
|
|
42
|
+
}
|
|
43
|
+
function typeDeclaredInDeclarationFile(packageName, declarationFiles, program) {
|
|
44
|
+
// Handle scoped packages: if the name starts with @, remove it and replace / with __
|
|
45
|
+
const typesPackageName = packageName.replace(/^@([^/]+)\//, '$1__');
|
|
46
|
+
const matcher = new RegExp(`${packageName}|${typesPackageName}`);
|
|
47
|
+
return declarationFiles.some(declaration => {
|
|
48
|
+
const packageIdName = program.sourceFileToPackageName.get(declaration.path);
|
|
49
|
+
return (packageIdName !== undefined &&
|
|
50
|
+
matcher.test(packageIdName) &&
|
|
51
|
+
program.isSourceFileFromExternalLibrary(declaration));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function typeDeclaredInPackageDeclarationFile(packageName, declarations, declarationFiles, program) {
|
|
55
|
+
return (typeDeclaredInDeclareModule(packageName, declarations) ||
|
|
56
|
+
typeDeclaredInDeclarationFile(packageName, declarationFiles, program));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=typeDeclaredInPackageDeclarationFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDeclaredInPackageDeclarationFile.js","sourceRoot":"","sources":["../../src/typeOrValueSpecifiers/typeDeclaredInPackageDeclarationFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,oFAUC;AAxDD,+CAAiC;AAEjC,SAAS,2BAA2B,CAClC,IAAa;IAEb,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB;YAClC,OAAO,EAAE,CAAC,eAAe,CAAE,IAA6B,CAAC,IAAI,CAAC;gBAC5D,CAAC,CAAE,IAA6B;gBAChC,CAAC,CAAC,SAAS,CAAC;QAChB,KAAK,EAAE,CAAC,UAAU,CAAC,UAAU;YAC3B,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,SAAS,2BAA2B,CAClC,WAAmB,EACnB,YAAuB;IAEvB,OAAO,YAAY,CAAC,IAAI,CACtB,WAAW,CAAC,EAAE,CACZ,2BAA2B,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,WAAW,CACtE,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CACpC,WAAmB,EACnB,gBAAiC,EACjC,OAAmB;IAEnB,qFAAqF;IACrF,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,WAAW,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACjE,OAAO,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QACzC,MAAM,aAAa,GAAG,OAAO,CAAC,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5E,OAAO,CACL,aAAa,KAAK,SAAS;YAC3B,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3B,OAAO,CAAC,+BAA+B,CAAC,WAAW,CAAC,CACrD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,oCAAoC,CAClD,WAAmB,EACnB,YAAuB,EACvB,gBAAiC,EACjC,OAAmB;IAEnB,OAAO,CACL,2BAA2B,CAAC,WAAW,EAAE,YAAY,CAAC;QACtD,6BAA6B,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC,CACtE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/type-utils",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.47",
|
|
4
4
|
"description": "Type utilities for working with TypeScript + ESLint together",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"typecheck": "tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@typescript-eslint/typescript-estree": "8.0.0-alpha.
|
|
50
|
-
"@typescript-eslint/utils": "8.0.0-alpha.
|
|
49
|
+
"@typescript-eslint/typescript-estree": "8.0.0-alpha.47",
|
|
50
|
+
"@typescript-eslint/utils": "8.0.0-alpha.47",
|
|
51
51
|
"debug": "^4.3.4",
|
|
52
52
|
"ts-api-utils": "^1.3.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@jest/types": "29.6.3",
|
|
56
|
-
"@typescript-eslint/parser": "8.0.0-alpha.
|
|
56
|
+
"@typescript-eslint/parser": "8.0.0-alpha.47",
|
|
57
57
|
"ajv": "^6.12.6",
|
|
58
58
|
"downlevel-dts": "*",
|
|
59
59
|
"jest": "29.7.0",
|