Skip to content

Array Type Generic

ErrorAuto-fixable
small-rules/array-type-generic

Disallow bracket array type syntax and require Array<T> / ReadonlyArray<T>.

Diagnostic Messages

useGenericArrayType
Bracket array type syntax is not allowed. Use Array<T> or ReadonlyArray<T> generic syntax.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/array-type-generic": "error"
}
}

Examples

Bracket array type syntax
type A = string[];

After auto-fix

type A = Array<string>;
Generic array type syntax
type Point = [x: number, y: number];