Content-Length: 2769 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/9788.patch

thub.com 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: [








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/9788.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy