{"record":{"id":"c629205ba38ed3e0","repo":"oxc-project/oxc","slug":"array-type-using-readonly-prefix-type-name-c62920","errorCode":null,"errorMessage":"Array type using '{readonly_prefix}{type_name}[]' is forbidden for non-simple types. Use '{name}<{type_name}>' instead.","messagePattern":"Array type using '(.+?)(.+?)\\[\\]' is forbidden for non-simple types\\. Use '(.+?)<(.+?)>' instead\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/typescript/array_type.rs","lineNumber":180,"sourceCode":"    /// ```\n    ArrayType,\n    typescript,\n    style,\n    fix,\n    config = ArrayTypeConfig,\n    version = \"0.2.8\",\n    short_description = \"Require consistently using either `T[]` or `Array<T>` for arrays.\",\n);\n\nfn generic(readonly_prefix: &str, name: &str, type_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Array type using '{readonly_prefix}{type_name}[]' is forbidden. Use '{name}<{type_name}>' instead.\"\n    ))\n    .with_label(span)\n}\n\nfn generic_simple(readonly_prefix: &str, name: &str, type_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Array type using '{readonly_prefix}{type_name}[]' is forbidden for non-simple types. Use '{name}<{type_name}>' instead.\"\n    ))\n    .with_label(span)\n}\n\nfn array(readonly_prefix: &str, type_name: &str, generic_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Array type using '{type_name}<{generic_name}>' is forbidden. Use '{readonly_prefix}{generic_name}[]' instead.\"\n    ))\n    .with_label(span)\n}\n\nfn array_simple(\n    readonly_prefix: &str,\n    type_name: &str,\n    generic_name: &str,\n    span: Span,\n) -> OxcDiagnostic {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/array_type.rs#L162-L198","documentation":"Diagnostic from the typescript `array-type` rule with the `generic-simple` option: bracket array syntax is forbidden only for non-simple element types. `string[]` stays legal, but object/union/function element types must use `Array<...>` because brackets around complex types read poorly.","triggerScenarios":"Config `{ \"array-type\": [\"error\", \"generic-simple\"] }`; check_and_report_error_generic skips simple types (primitives, literals) but reports `TSArrayType` whose element is non-simple — `type Ps = { name: string }[]`, `let xs: (string | number)[]`, `readonly User[]` — telling you to use `Array<{ name: string }>` etc. Autofix included.","commonSituations":"Adopting the ESLint-compatible hybrid convention; enabling after a merge of codebases with mixed styles; hits cluster in React prop types (`props: Props[]`) and API DTO layers full of object types.","solutions":["Run `oxlint --fix` to convert only the non-simple offenders to `Array<...>`.","Rewrite manually: `let users: Array<User>` for object/union elements, keep `number[]` for primitives.","Re-check the option if you intended the stricter blanket `generic` rule instead of the simple-type carve-out."],"exampleFix":"// before\ntype Points = { x: number; y: number }[];\nlet mixed: (string | number)[] = [];\n\n// after\ntype Points = Array<{ x: number; y: number }>;\nlet mixed: Array<string | number> = [];","handlingStrategy":"fallback","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick 'generic-simple' only if the team accepts two spellings; otherwise use 'generic' for one rule everywhere.","Autofix is safe here — run `oxlint --fix` once per migration and review the diff.","Exclude generated folders or configure them separately if they intentionally use bracket syntax for complex types."],"tags":["typescript","oxlint","style","types","autofix","array-type"],"backgroundTag":"typescript-array-type-style","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}