Content-Length: 359678 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/9788/files

3F fix(utils): add `TSDeclareFunction` to `functionTypeTypes` by abrahamguo · Pull Request #9788 · typescript-eslint/typescript-eslint · GitHub
Skip to content

fix(utils): add TSDeclareFunction to functionTypeTypes #9788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
arrayGroupByToMap,
createRule,
getParserServices,
isFunction,
isFunctionType,
isFunctionOrFunctionType,
isTypeAnyType,
isTypeBigIntLiteralType,
isTypeNeverType,
Expand Down Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isFunctionOrFunctionType simply combines the checks of the two functions into one

);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/ast-utils/predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading








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/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy