{"record":{"id":"c25cb45d1a8ba9b7","repo":"oxc-project/oxc","slug":"array-type-using-type-name-generic-name-is-c25cb4","errorCode":null,"errorMessage":"Array type using '{type_name}<{generic_name}>' is forbidden for simple types. Use '{readonly_prefix}{generic_name}[]' instead.","messagePattern":"Array type using '(.+?)<(.+?)>' is forbidden for simple types\\. Use '(.+?)(.+?)\\[\\]' instead\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/typescript/array_type.rs","lineNumber":199,"sourceCode":"        \"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 {\n    OxcDiagnostic::warn(format!(\n        \"Array type using '{type_name}<{generic_name}>' is forbidden for simple types. Use '{readonly_prefix}{generic_name}[]' instead.\"\n    ))\n    .with_label(span)\n}\n\nimpl Rule for ArrayType {\n    fn from_configuration(value: serde_json::Value) -> Result<Self, serde_json::error::Error> {\n        DefaultRuleConfig::<Self>::from_value(value).map(DefaultRuleConfig::into_inner)\n    }\n\n    fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {\n        match node.kind() {\n            AstKind::TSArrayType(ts_array_type) => {\n                check_array_type(\n                    node,\n                    ts_array_type.span,\n                    &ts_array_type.element_type,\n                    self.default_config(),","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/array_type.rs#L181-L217","documentation":"Diagnostic from the typescript `array-type` rule with the `array-simple` option: `Array<T>` is forbidden only when the element type is simple (primitives, literal types). Complex elements keep `Array<...>`; simple ones must use bracket syntax, matching the common hybrid style guide.","triggerScenarios":"Config `{ \"array-type\": [\"error\", \"array-simple\"] }`; in check_and_report_error_array, `Array<string>`, `Array<number>`, `ReadonlyArray<'a' | 'b'>` are flagged ('forbidden for simple types. Use ...[] instead.'), while `Array<{ id: number }>` is left alone. Autofix included.","commonSituations":"Teams that want `number[]` but also want `Array<{ complex }>` for readability; enabling the option across a repo where DTO code uses `Array<string>` from a generator; inconsistency reported after partial autofix runs.","solutions":["Run `oxlint --fix` to convert only simple-element `Array<T>` to `T[]`.","Rewrite manually: `let xs: string[]` while keeping `let rows: Array<Row>`.","Confirm the option matches intent: if everything should be `T[]`, use plain `array`; if everything generic, use `generic`."],"exampleFix":"// before\nlet xs: Array<string> = [];\ntype Flags = ReadonlyArray<'on' | 'off'>;\n\n// after\nlet xs: string[] = [];\ntype Flags = readonly ('on' | 'off')[];","handlingStrategy":"fallback","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the hybrid rule for the team: simple types get `T[]`, complex types get `Array<T>`.","Let the autofix do the conversion; manual rewrites miss edge cases like `ReadonlyArray<'a'|'b'>`.","Re-run the linter after autofix to catch nested cases (e.g. `Array<Array<string>>`) that need a second pass."],"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-14T05:17:10.506Z"}