From 4e508e1677ee28dcce7b0efc8afb030d428fedaa Mon Sep 17 00:00:00 2001 From: Abraham Guo Date: Tue, 13 Aug 2024 08:33:02 -0500 Subject: [PATCH 1/2] add tsdeclarefunction --- packages/utils/src/ast-utils/predicates.ts | 1 + 1 file changed, 1 insertion(+) 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, From 5a425ffc10bd389b9b3a1fabe2cd98575c974b52 Mon Sep 17 00:00:00 2001 From: Abraham Guo Date: Tue, 13 Aug 2024 20:57:49 -0500 Subject: [PATCH 2/2] add newly valid test --- .../src/rules/no-redundant-type-constituents.ts | 5 ++--- .../tests/rules/no-redundant-type-constituents.test.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) 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: [ 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