Skip to content

typescript/consistent-indexed-object-style Style

🛠️ An auto-fix is available for this rule for some violations.

What it does

Require or disallow the Record type.

Why is this bad?

Inconsistent style for indexed object types can harm readability in a project.

Examples

Examples of incorrect code for this rule:

ts
interface Foo {
  [key: string]: unknown;
}
type Foo = {
  [key: string]: unknown;
};

Examples of correct code for this rule:

ts
type Foo = Record<string, unknown>;

References

Released under the MIT License.