diff --git a/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts b/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts index 0c6d6c826123..735a6d8883c2 100644 --- a/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts +++ b/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts @@ -6,8 +6,7 @@ import { arrayGroupByToMap, createRule, getParserServices, - isFunction, - isFunctionType, + isFunctionOrFunctionType, isTypeAnyType, isTypeBigIntLiteralType, isTypeNeverType, @@ -171,7 +170,7 @@ function describeLiteralTypeNode(typeNode: TSESTree.TypeNode): string { function isNodeInsideReturnType(node: TSESTree.TSUnionType): boolean { return !!( node.parent.type === AST_NODE_TYPES.TSTypeAnnotation && - (isFunctionType(node.parent.parent) || isFunction(node.parent.parent)) + isFunctionOrFunctionType(node.parent.parent) ); } diff --git a/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts b/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts index 0e48dbd1c24e..90c1453dbe89 100644 --- a/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts +++ b/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts @@ -165,6 +165,7 @@ ruleTester.run('no-redundant-type-constituents', rule, { type T = 'a' | 1 | 'b'; type U = T & string; `, + "declare function fn(): never | 'foo';", ], invalid: [ diff --git a/packages/utils/src/ast-utils/predicates.ts b/packages/utils/src/ast-utils/predicates.ts index 2d0c3831a877..3549fb171578 100644 --- a/packages/utils/src/ast-utils/predicates.ts +++ b/packages/utils/src/ast-utils/predicates.ts @@ -71,6 +71,7 @@ const functionTypeTypes = [ AST_NODE_TYPES.TSCallSignatureDeclaration, AST_NODE_TYPES.TSConstructorType, AST_NODE_TYPES.TSConstructSignatureDeclaration, + AST_NODE_TYPES.TSDeclareFunction, AST_NODE_TYPES.TSEmptyBodyFunctionExpression, AST_NODE_TYPES.TSFunctionType, AST_NODE_TYPES.TSMethodSignature, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy