@typescript-eslint/type-utils
Advanced tools
Comparing version 8.21.1-alpha.3 to 8.21.1-alpha.4
@@ -138,22 +138,34 @@ "use strict"; | ||
function typeMatchesSpecifier(type, specifier, program) { | ||
if (tsutils.isIntrinsicErrorType(type)) { | ||
return false; | ||
const wholeTypeMatches = (() => { | ||
if (tsutils.isIntrinsicErrorType(type)) { | ||
return false; | ||
} | ||
if (typeof specifier === 'string') { | ||
return (0, specifierNameMatches_1.specifierNameMatches)(type, specifier); | ||
} | ||
if (!(0, specifierNameMatches_1.specifierNameMatches)(type, specifier.name)) { | ||
return false; | ||
} | ||
const symbol = type.getSymbol() ?? type.aliasSymbol; | ||
const declarations = symbol?.getDeclarations() ?? []; | ||
const declarationFiles = declarations.map(declaration => declaration.getSourceFile()); | ||
switch (specifier.from) { | ||
case 'file': | ||
return (0, typeDeclaredInFile_1.typeDeclaredInFile)(specifier.path, declarationFiles, program); | ||
case 'lib': | ||
return (0, typeDeclaredInLib_1.typeDeclaredInLib)(declarationFiles, program); | ||
case 'package': | ||
return (0, typeDeclaredInPackageDeclarationFile_1.typeDeclaredInPackageDeclarationFile)(specifier.package, declarations, declarationFiles, program); | ||
} | ||
})(); | ||
if (wholeTypeMatches) { | ||
return true; | ||
} | ||
if (typeof specifier === 'string') { | ||
return (0, specifierNameMatches_1.specifierNameMatches)(type, specifier); | ||
if (tsutils.isIntersectionType(type) && | ||
tsutils | ||
.intersectionTypeParts(type) | ||
.some(part => typeMatchesSpecifier(part, specifier, program))) { | ||
return true; | ||
} | ||
if (!(0, specifierNameMatches_1.specifierNameMatches)(type, specifier.name)) { | ||
return false; | ||
} | ||
const symbol = type.getSymbol() ?? type.aliasSymbol; | ||
const declarations = symbol?.getDeclarations() ?? []; | ||
const declarationFiles = declarations.map(declaration => declaration.getSourceFile()); | ||
switch (specifier.from) { | ||
case 'file': | ||
return (0, typeDeclaredInFile_1.typeDeclaredInFile)(specifier.path, declarationFiles, program); | ||
case 'lib': | ||
return (0, typeDeclaredInLib_1.typeDeclaredInLib)(declarationFiles, program); | ||
case 'package': | ||
return (0, typeDeclaredInPackageDeclarationFile_1.typeDeclaredInPackageDeclarationFile)(specifier.package, declarations, declarationFiles, program); | ||
} | ||
return false; | ||
} | ||
@@ -160,0 +172,0 @@ const typeMatchesSomeSpecifier = (type, specifiers = [], program) => specifiers.some(specifier => typeMatchesSpecifier(type, specifier, program)); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || (function () { | ||
var ownKeys = function(o) { | ||
ownKeys = Object.getOwnPropertyNames || function (o) { | ||
var ar = []; | ||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
return ar; | ||
}; | ||
return ownKeys(o); | ||
}; | ||
return function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.specifierNameMatches = specifierNameMatches; | ||
const tsutils = __importStar(require("ts-api-utils")); | ||
function specifierNameMatches(type, names) { | ||
@@ -49,7 +15,4 @@ if (typeof names === 'string') { | ||
} | ||
if (tsutils.isIntersectionType(type)) { | ||
return type.types.some(subType => specifierNameMatches(subType, names)); | ||
} | ||
return false; | ||
} | ||
//# sourceMappingURL=specifierNameMatches.js.map |
{ | ||
"name": "@typescript-eslint/type-utils", | ||
"version": "8.21.1-alpha.3", | ||
"version": "8.21.1-alpha.4", | ||
"description": "Type utilities for working with TypeScript + ESLint together", | ||
@@ -49,4 +49,4 @@ "files": [ | ||
"dependencies": { | ||
"@typescript-eslint/typescript-estree": "8.21.1-alpha.3", | ||
"@typescript-eslint/utils": "8.21.1-alpha.3", | ||
"@typescript-eslint/typescript-estree": "8.21.1-alpha.4", | ||
"@typescript-eslint/utils": "8.21.1-alpha.4", | ||
"debug": "^4.3.4", | ||
@@ -61,3 +61,3 @@ "ts-api-utils": "^2.0.0" | ||
"@jest/types": "29.6.3", | ||
"@typescript-eslint/parser": "8.21.1-alpha.3", | ||
"@typescript-eslint/parser": "8.21.1-alpha.4", | ||
"ajv": "^6.12.6", | ||
@@ -64,0 +64,0 @@ "downlevel-dts": "*", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
125686
1937
+ Added@typescript-eslint/scope-manager@8.21.1-alpha.4(transitive)
+ Added@typescript-eslint/types@8.21.1-alpha.4(transitive)
+ Added@typescript-eslint/typescript-estree@8.21.1-alpha.4(transitive)
+ Added@typescript-eslint/utils@8.21.1-alpha.4(transitive)
+ Added@typescript-eslint/visitor-keys@8.21.1-alpha.4(transitive)
- Removed@typescript-eslint/scope-manager@8.21.1-alpha.3(transitive)
- Removed@typescript-eslint/types@8.21.1-alpha.3(transitive)
- Removed@typescript-eslint/typescript-estree@8.21.1-alpha.3(transitive)
- Removed@typescript-eslint/utils@8.21.1-alpha.3(transitive)
- Removed@typescript-eslint/visitor-keys@8.21.1-alpha.3(transitive)