Skip to content

indexedObjectTypes

Reports indexed object types that don't match the configured style.

✅ This rule is included in the ts stylistic and stylisticStrict presets.

TypeScript provides two equivalent ways to define indexed object types: Record<K, V> and { [key: K]: V }. Using one style consistently improves code readability.

This rule enforces consistent usage of either Record<K, V> (default) or index signatures.

AEinterfa53 Data< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3[sp ansty="le--0:#D7DBE0;--1:#403F">53k7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri5<3]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">B0numb5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEty53 StringMa

A

<53sp ansty="le--0:#D6DE">EB {< [sp ansty="le--0:#D7DB">E0k7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri5<3]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">B0stri53
<};d ivclassNa="meco"><};d>
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0proce1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53da7<2:sp ansty="le--1:#403F"><53sp ansty="le--0:#D6DE">EB {< [sp ansty="le--0:#D7DB">E0k7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri5<3]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">B0numb53< }sp ansty="le--0:#D9F5DD;--1:#1111">1<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>
44AE3F53 D4<4AE= spans="tyle--0:#D6DEEB;--1:#40">31111Re361B0st3F<53, spans="tyle--0:#C5E478;--1:#3B">61B0nu3F<53> ;divclass="Name">>>><;di vdivclass="Nameexpressive-">44AE3F53 String4<4AE= spans="tyle--0:#D6DEEB;--1:#40">31111Re361B0st3F<53, spans="tyle--0:#C5E478;--1:#3B">61B0st3F<53> ;divclass="Name">>>><;di vdivclass="Nameexpressive-">44AEfunc361B0pro1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53631111Re361B0st6<67B, spans="tyle--0:#D6DEEB;--1:#40">361B0nu3 spans="tyle--0:#D9F5DD;--1:#11">1><111) spans="tyle--0:#7FDBCA;--1:#09">6361B03F5<3 { }divclass="Name">
  • "record" (default): Prefer Record<K, V> over index signatures.
  • "index-signature": Prefer index signatures over Record<K, V>.

When set to "index-signature":

AEty53 DatA5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Reco5<3B0stri53<, sp ansty="le--0:#C5E478;--1:#3B61">B0numb53<>;d ivclassNa="meco"><>;d>;d>;d>
44AE3F53 D4<4AE= spans="tyle--1:#40"><3F53 spans="tyle--0:#D6">DEEB< { [ spans="tyle--0:#D7">DBE<0key spans="tyle--0:#7FDBCA;--1:#09">6361B0st36361B0nu3F5<3 } ;divclass="Name">

If your project already has an established convention for indexed object types that you don’t want to enforce, or if you prefer allowing both styles for flexibility, you may disable this rule.