@typescript-eslint/eslint-plugin 8.59.1-alpha.3 → 8.59.1-alpha.5
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.
|
@@ -223,9 +223,8 @@ exports.default = (0, util_1.createRule)({
|
|
|
223
223
|
.some(part => checker.getIndexInfosOfType(part).length > 0);
|
|
224
224
|
}
|
|
225
225
|
function getTypeArguments(type) {
|
|
226
|
-
return
|
|
227
|
-
? checker.getTypeArguments(type)
|
|
228
|
-
: [];
|
|
226
|
+
return (type.aliasTypeArguments ??
|
|
227
|
+
(tsutils.isTypeReference(type) ? checker.getTypeArguments(type) : []));
|
|
229
228
|
}
|
|
230
229
|
function typeContains(type, predicate, seen = new Set()) {
|
|
231
230
|
if (seen.has(type)) {
|
|
@@ -255,6 +254,9 @@ exports.default = (0, util_1.createRule)({
|
|
|
255
254
|
function containsTypeVariable(type) {
|
|
256
255
|
return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.TypeVariable | ts.TypeFlags.Index));
|
|
257
256
|
}
|
|
257
|
+
function hasPhantomTypeArguments(type) {
|
|
258
|
+
return isEmptyObjectType(type) && getTypeArguments(type).length > 0;
|
|
259
|
+
}
|
|
258
260
|
function hasTypeParams(sig) {
|
|
259
261
|
return (sig.getTypeParameters()?.length ?? 0) > 0;
|
|
260
262
|
}
|
|
@@ -488,6 +490,12 @@ exports.default = (0, util_1.createRule)({
|
|
|
488
490
|
}
|
|
489
491
|
return false;
|
|
490
492
|
}
|
|
493
|
+
function hasPhantomTypeArgumentMismatch(node, uncastType, contextualType) {
|
|
494
|
+
return (isInGenericContext(node) &&
|
|
495
|
+
(hasPhantomTypeArguments(uncastType) ||
|
|
496
|
+
hasPhantomTypeArguments(contextualType)) &&
|
|
497
|
+
!haveSameTypeArguments(uncastType, contextualType));
|
|
498
|
+
}
|
|
491
499
|
const SKIP_PARENT_TYPES = new Set([
|
|
492
500
|
utils_1.AST_NODE_TYPES.TSAsExpression,
|
|
493
501
|
utils_1.AST_NODE_TYPES.TSTypeAssertion,
|
|
@@ -619,6 +627,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
619
627
|
const isContextuallyUnnecessary = !typeAnnotationIsConstAssertion &&
|
|
620
628
|
!containsAny(uncastType) &&
|
|
621
629
|
anyInvolvedInContextualCheck &&
|
|
630
|
+
!hasPhantomTypeArgumentMismatch(node, uncastType, contextualType) &&
|
|
622
631
|
(castIsAny || !genericsMismatch(uncastType, contextualType)) &&
|
|
623
632
|
(contextualTypeIsAny ||
|
|
624
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.5",
|
|
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/
|
|
56
|
-
"@typescript-eslint/type-utils": "8.59.1-alpha.
|
|
57
|
-
"@typescript-eslint/
|
|
58
|
-
"@typescript-eslint/
|
|
55
|
+
"@typescript-eslint/utils": "8.59.1-alpha.5",
|
|
56
|
+
"@typescript-eslint/type-utils": "8.59.1-alpha.5",
|
|
57
|
+
"@typescript-eslint/visitor-keys": "8.59.1-alpha.5",
|
|
58
|
+
"@typescript-eslint/scope-manager": "8.59.1-alpha.5"
|
|
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-schema-to-typescript-types": "8.59.1-alpha.
|
|
82
|
-
"@typescript-eslint/rule-tester": "8.59.1-alpha.
|
|
81
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.59.1-alpha.5",
|
|
82
|
+
"@typescript-eslint/rule-tester": "8.59.1-alpha.5"
|
|
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.5"
|
|
88
88
|
},
|
|
89
89
|
"funding": {
|
|
90
90
|
"type": "opencollective",
|