diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 3c0cad93ed1..35cfaaf1fc1 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -61,6 +61,7 @@ function typeNeedsParentheses(node: TSESTree.Node): boolean { case AST_NODE_TYPES.TSIntersectionType: case AST_NODE_TYPES.TSTypeOperator: case AST_NODE_TYPES.TSInferType: + case AST_NODE_TYPES.TSConstructorType: return true; case AST_NODE_TYPES.Identifier: return node.name === 'ReadonlyArray'; diff --git a/packages/eslint-plugin/tests/rules/array-type.test.ts b/packages/eslint-plugin/tests/rules/array-type.test.ts index a00f72cdba1..b2c6a5d177d 100644 --- a/packages/eslint-plugin/tests/rules/array-type.test.ts +++ b/packages/eslint-plugin/tests/rules/array-type.test.ts @@ -1885,6 +1885,36 @@ interface FooInterface { }, ], }, + { + code: 'const foo: Array void> = [];', + output: 'const foo: (new (...args: any[]) => void)[] = [];', + options: [{ default: 'array' }], + errors: [ + { + messageId: 'errorStringArray', + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, + line: 1, + column: 12, + }, + ], + }, + { + code: 'const foo: ReadonlyArray void> = [];', + output: 'const foo: readonly (new (...args: any[]) => void)[] = [];', + options: [{ default: 'array' }], + errors: [ + { + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, + line: 1, + column: 12, + }, + ], + }, ], });