Skip to content

Commit

Permalink
fix(eslint-plugin): [sort-type-union-intersection-members] Wrap the c…
Browse files Browse the repository at this point in the history
…onstructorType in parentheses (#4590)

Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
  • Loading branch information
islandryu and JoshuaKGoldberg committed Feb 24, 2022
1 parent 6afcaea commit 851bb90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -85,7 +85,10 @@ function getGroup(node: TSESTree.TypeNode): Group {
}

function requiresParentheses(node: TSESTree.TypeNode): boolean {
return node.type === AST_NODE_TYPES.TSFunctionType;
return (
node.type === AST_NODE_TYPES.TSFunctionType ||
node.type === AST_NODE_TYPES.TSConstructorType
);
}

export type Options = [
Expand Down
Expand Up @@ -272,6 +272,15 @@ type T =
},
],
},
{
code: `type Expected = (new (x: number) => boolean) ${operator} string;`,
output: `type Expected = string ${operator} (new (x: number) => boolean);`,
errors: [
{
messageId: 'notSortedNamed',
},
],
},
];
};

Expand Down

0 comments on commit 851bb90

Please sign in to comment.