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.

AEconsB0valu7<2:sp ansty="le--0:#C792EA;--1:#8844">A11ArrAB0striAE>< =sp ansty="le--0:#D6DEEB;--1:#403F">53 [<];d ivclassNa="meco"><];d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0proce1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53ite7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Arr5<3B0numb5<3>sp ansty="le--0:#D9F5DD;--1:#1111">1sp><1)sp ansty="le--0:#7FDBCA;--1:#096E">7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0vo53 <{}d ivclassNa="meco"><{}d>AEty53 StringArraA5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Arr5<3B0stri53<>;d ivclassNa="meco"><>;d>;d>;d>AEconsB0valu7<2:sp ansty="le--0:#C792EA;--1:#8844">A11ReadonlyArrAB0striAE>< =sp ansty="le--0:#D6DEEB;--1:#403F">53 [<];d ivclassNa="meco"><];d>
44AEco61B0va64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0st3F<53[] spans="tyle--0:#C792EA;--1:#88">443F53< [] ;divclass="Name">< []><;di vdivclass="Nameexpressive-">44AEfunc361B0pro1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53i6361B0nu3F<53[] spans="tyle--0:#D9F5DD;--1:#11">1<111) spans="tyle--0:#7FDBCA;--1:#09">6361B03F5<3 { }divclass="Name"><}di vdivclass="Nameexpressive-">44AE3F53 StringAr4<4AE= spans="tyle--0:#D6DEEB;--1:#40">361B0st3F5<3[] ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEco61B0va644AE reado61B0st3F<53[] spans="tyle--0:#C792EA;--1:#88">443F53< [] ;divclass="Name">< []>

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.