Content-Length: 2087 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/9788.diff
thub.com 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,Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/9788.diff
Alternative Proxies: