Skip to content

objectTypeDefinitions

Prefer interface declarations over type aliases for object types.

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

TypeScript allows describing an object’s shape with either an interface declaration or a type alias of an object literal type. Interfaces support declaration merging, can be extended with the extends keyword, and can be implemented by classes. TypeScript’s error messages and hover information also tend to show an interface’s name directly, where a type alias may be expanded into its full object type.

This rule reports type aliases whose type is an object literal type, such as type Box = { value: string }. Type aliases of other types, such as unions, intersections, and mapped types, are not reported because they can’t be written as interfaces.

type Box = { value: string };
type Point = {
x: number;
y: number;
};

This rule is not configurable.

If your project has a convention of declaring object types with type aliases, such as to prevent declaration merging from adding properties to a type in other files, this rule will report each of those declarations. You might prefer to disable this rule if converting them is not worth the churn in a large existing codebase.