Skip to content

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.

const values: Array<string> = [];
function process(items: Array<number>): void {}
type StringArray = Array<string>;
const values: ReadonlyArray<string> = [];

This rule is not configurable.

If your codebase uses Array<T> consistently, or if you prefer the generic syntax for its explicit nature, you may disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.