mpellegrini / fullstack-typescript-monorepo-starter

1 stars 1 forks source link

ESLint Toolchain: Implement the consistent-indexed-object-style rule #132

Closed mpellegrini closed 1 month ago

mpellegrini commented 1 month ago

TypeScript supports defining arbitrary object keys using an index signature. TypeScript also has a builtin type named Record to create an empty object defining only an index signature. For example, the following types are equal:

interface Foo {
  [key: string]: unknown;
}

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

type Foo = Record<string, unknown>;

Using one declaration form consistently improves code readability.