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.

interface Data {
[key: string]: number;
}
type StringMap = { [key: string]: string };
function process(data: { [key: string]: number }): void {}
  • "record" (default): Prefer Record<K, V> over index signatures.
  • "index-signature": Prefer index signatures over Record<K, V>.

When set to "index-signature":

type Data = Record<string, number>;

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.

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