Skip to content

arrayTypes

Reports array type syntax that doesn't match the configured style.

✅ This rule is included in the ts stylistic and stylisticStrict 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
const values: string[]
values
:
interface Array<T>
Array
<string> = [];
function
function process(items: Array<number>): void
process
(
items: number[]
items
:
interface Array<T>
Array
<number>): void {}
type
type StringArray = string[]
StringArray
=
interface Array<T>
Array
<string>;
const
const values: readonly string[]
values
:
interface ReadonlyArray<T>
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 ❤️‍🔥 around the world by the Flint team and contributors.