Empty interface Declaration

ID

javascript.ts_no_empty_interface

Severity

low

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

JavaScript

Tags

types, typescript

Description

Reports interface declarations whose body has no members. An empty interface declares no contract; readers cannot tell whether it is a placeholder for future expansion, a stub left from a refactor, or a deliberate marker type.

Rationale

// Bad — declares nothing.
interface Empty {}
interface Marker {
}
interface ExtendsButEmpty extends Marker {}

An empty interface that extends another type is interchangeable with the parent type and almost always indicates a forgotten member or a confused alias. An empty interface that does not extend anything is even less useful — it accepts everything (every value is assignable to {}) and signals the absence of a real contract.

Remediation

Add the members the interface is meant to describe, or — when the goal is purely a name alias — use a type alias:

// Good — concrete contract.
interface User {
  id: string;
  name: string;
}

// Good — type alias when no interface-specific feature is needed.
type Marker = SomeBase;

// Good — branded type for nominal typing without an empty body.
interface UserId {
  readonly _brand: unique symbol;
}