arrayTypes
Reports array type syntax that doesn't match the configured style.
✅ This rule is included in the ts stylistic presets.
TypeScript provides two equivalent ways to define an array type: T[] and Array<T>.
Using the shorthand T[] syntax consistently is more concise and idiomatic.
This rule reports when Array<T> or ReadonlyArray<T> is used instead of the shorthand syntax.
Examples
Section titled “Examples”const values: Array<string> = [];function process(items: Array<number>): void {}type StringArray = Array<string>;const values: ReadonlyArray<string> = [];const values: string[] = [];function process(items: number[]): void {}type StringArray = string[];const values: readonly string[] = [];Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your codebase uses Array<T> consistently, or if you prefer the generic syntax for its explicit nature, you may disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useConsistentArrayType - ESLint:
@typescript-eslint/array-type - Oxlint:
typescript/array-type
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.