Skip to content

emptyObjectTypes

Reports empty object type literals and empty interfaces that are often used incorrectly.

✅ This rule is included in the ts logical and logicalStrict presets.

The {} (“empty object”) type in TypeScript is a common source of confusion. It actually represents any non-nullish value, not an empty object. This includes primitives like strings and numbers.

Similarly, an empty interface interface Foo {} is equivalent to {}.

If you want to represent any object, use object. If you want any value, use unknown.

type Empty = {};
interface Empty {}
let value: {};
function foo(param: {}) {}

This rule is not configurable.

If your code commonly needs to represent the “any non-nullish value” type, this rule may not be for you. Projects that extensively use type operations such as conditional types and mapped types may benefit from disabling this rule.