@typescript-eslint/eslint-plugin 8.59.1-alpha.2 → 8.59.1-alpha.4
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.
|
@@ -218,12 +218,13 @@ exports.default = (0, util_1.createRule)({
|
|
|
218
218
|
return type.isLiteral() || tsutils.isBooleanLiteralType(type);
|
|
219
219
|
}
|
|
220
220
|
function hasIndexSignature(type) {
|
|
221
|
-
return
|
|
221
|
+
return tsutils
|
|
222
|
+
.unionConstituents(type)
|
|
223
|
+
.some(part => checker.getIndexInfosOfType(part).length > 0);
|
|
222
224
|
}
|
|
223
225
|
function getTypeArguments(type) {
|
|
224
|
-
return
|
|
225
|
-
? checker.getTypeArguments(type)
|
|
226
|
-
: [];
|
|
226
|
+
return (type.aliasTypeArguments ??
|
|
227
|
+
(tsutils.isTypeReference(type) ? checker.getTypeArguments(type) : []));
|
|
227
228
|
}
|
|
228
229
|
function typeContains(type, predicate, seen = new Set()) {
|
|
229
230
|
if (seen.has(type)) {
|
|
@@ -253,6 +254,9 @@ exports.default = (0, util_1.createRule)({
|
|
|
253
254
|
function containsTypeVariable(type) {
|
|
254
255
|
return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.TypeVariable | ts.TypeFlags.Index));
|
|
255
256
|
}
|
|
257
|
+
function hasPhantomTypeArguments(type) {
|
|
258
|
+
return isEmptyObjectType(type) && getTypeArguments(type).length > 0;
|
|
259
|
+
}
|
|
256
260
|
function hasTypeParams(sig) {
|
|
257
261
|
return (sig.getTypeParameters()?.length ?? 0) > 0;
|
|
258
262
|
}
|
|
@@ -486,6 +490,12 @@ exports.default = (0, util_1.createRule)({
|
|
|
486
490
|
}
|
|
487
491
|
return false;
|
|
488
492
|
}
|
|
493
|
+
function hasPhantomTypeArgumentMismatch(node, uncastType, contextualType) {
|
|
494
|
+
return (isInGenericContext(node) &&
|
|
495
|
+
(hasPhantomTypeArguments(uncastType) ||
|
|
496
|
+
hasPhantomTypeArguments(contextualType)) &&
|
|
497
|
+
!haveSameTypeArguments(uncastType, contextualType));
|
|
498
|
+
}
|
|
489
499
|
const SKIP_PARENT_TYPES = new Set([
|
|
490
500
|
utils_1.AST_NODE_TYPES.TSAsExpression,
|
|
491
501
|
utils_1.AST_NODE_TYPES.TSTypeAssertion,
|
|
@@ -617,6 +627,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
617
627
|
const isContextuallyUnnecessary = !typeAnnotationIsConstAssertion &&
|
|
618
628
|
!containsAny(uncastType) &&
|
|
619
629
|
anyInvolvedInContextualCheck &&
|
|
630
|
+
!hasPhantomTypeArgumentMismatch(node, uncastType, contextualType) &&
|
|
620
631
|
(castIsAny || !genericsMismatch(uncastType, contextualType)) &&
|
|
621
632
|
(contextualTypeIsAny ||
|
|
622
633
|
checker.isTypeAssignableTo(uncastType, contextualType)) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.59.1-alpha.
|
|
3
|
+
"version": "8.59.1-alpha.4",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"ignore": "^7.0.5",
|
|
53
53
|
"natural-compare": "^1.4.0",
|
|
54
54
|
"ts-api-utils": "^2.5.0",
|
|
55
|
-
"@typescript-eslint/scope-manager": "8.59.1-alpha.
|
|
56
|
-
"@typescript-eslint/type-utils": "8.59.1-alpha.
|
|
57
|
-
"@typescript-eslint/
|
|
58
|
-
"@typescript-eslint/
|
|
55
|
+
"@typescript-eslint/scope-manager": "8.59.1-alpha.4",
|
|
56
|
+
"@typescript-eslint/type-utils": "8.59.1-alpha.4",
|
|
57
|
+
"@typescript-eslint/utils": "8.59.1-alpha.4",
|
|
58
|
+
"@typescript-eslint/visitor-keys": "8.59.1-alpha.4"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/json-schema": "^7.0.15",
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"typescript": ">=4.8.4 <6.1.0",
|
|
79
79
|
"unist-util-visit": "^5.0.0",
|
|
80
80
|
"vitest": "^4.0.18",
|
|
81
|
-
"@typescript-eslint/rule-tester": "8.59.1-alpha.
|
|
82
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.59.1-alpha.
|
|
81
|
+
"@typescript-eslint/rule-tester": "8.59.1-alpha.4",
|
|
82
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.59.1-alpha.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
86
86
|
"typescript": ">=4.8.4 <6.1.0",
|
|
87
|
-
"@typescript-eslint/parser": "^8.59.1-alpha.
|
|
87
|
+
"@typescript-eslint/parser": "^8.59.1-alpha.4"
|
|
88
88
|
},
|
|
89
89
|
"funding": {
|
|
90
90
|
"type": "opencollective",
|